]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/store/postgresql/postgresql_store_admins.cpp
Simplified STG_LOCKER.
[stg.git] / projects / stargazer / plugins / store / postgresql / postgresql_store_admins.cpp
index d14f3a4d5a72dc59a8b0cd4db17ac179cc1fc85b..63cf3d5ce0eba7d2fbcca0ff1b28e2e6c868f1d9 100644 (file)
@@ -21,8 +21,8 @@
 /*
  *  Administrators manipulation methods
  *
- *  $Revision: 1.2 $
- *  $Date: 2009/06/09 12:32:39 $
+ *  $Revision: 1.3 $
+ *  $Date: 2010/11/08 10:10:24 $
  *
  */
 
 
 #include <libpq-fe.h>
 
+#include "stg/locker.h"
+#include "stg/admin_conf.h"
+#include "stg/blowfish.h"
 #include "postgresql_store.h"
-#include "stg_locker.h"
-#include "admin_conf.h"
-#include "blowfish.h"
 
 #define adm_enc_passwd "cjeifY8m3"
 
 //-----------------------------------------------------------------------------
 int POSTGRESQL_STORE::GetAdminsList(std::vector<std::string> * adminsList) const
 {
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
 
 if (PQstatus(connection) != CONNECTION_OK)
     {
@@ -98,7 +98,7 @@ return 0;
 //-----------------------------------------------------------------------------
 int POSTGRESQL_STORE::SaveAdmin(const ADMIN_CONF & ac) const
 {
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
 
 if (PQstatus(connection) != CONNECTION_OK)
     {
@@ -134,10 +134,10 @@ for (int i = 0; i < ADM_PASSWD_LEN / 8; i++)
 cryptedPass[ADM_PASSWD_LEN] = 0;
 Encode12(encodedPass, cryptedPass, ADM_PASSWD_LEN);
 
-std::string password = encodedPass;
+std::string pass = encodedPass;
 std::string login = ac.login;
 
-if (EscapeString(password))
+if (EscapeString(pass))
     {
     printfd(__FILE__, "POSTGRESQL_STORE::SaveAdmin(): 'Failed to escape password'\n");
     if (RollbackTransaction())
@@ -159,7 +159,7 @@ if (EscapeString(login))
 
 std::stringstream query;
 query << "UPDATE tb_admins SET "
-          << "passwd = '" << password << "', "
+          << "passwd = '" << pass << "', "
           << "chg_conf = " << ac.priv.userConf << ", "
           << "chg_password = " << ac.priv.userPasswd << ", "
           << "chg_stat = " << ac.priv.userStat << ", "
@@ -195,9 +195,9 @@ return 0;
 }
 
 //-----------------------------------------------------------------------------
-int POSTGRESQL_STORE::RestoreAdmin(ADMIN_CONF * ac, const string & login) const
+int POSTGRESQL_STORE::RestoreAdmin(ADMIN_CONF * ac, const std::string & login) const
 {
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
 
 if (PQstatus(connection) != CONNECTION_OK)
     {
@@ -234,7 +234,7 @@ if (EscapeString(elogin))
     return -1;
     }
 
-std::stringstream query;
+std::ostringstream query;
 query << "SELECT login, passwd, \
                  chg_conf, chg_password, chg_stat, \
                  chg_cash, usr_add_del, chg_tariff, \
@@ -316,9 +316,9 @@ ac->password = adminPass;
 return 0;
 }
 //-----------------------------------------------------------------------------
-int POSTGRESQL_STORE::AddAdmin(const string & login) const
+int POSTGRESQL_STORE::AddAdmin(const std::string & login) const
 {
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
 
 if (PQstatus(connection) != CONNECTION_OK)
     {
@@ -351,7 +351,7 @@ if (EscapeString(elogin))
     return -1;
     }
 
-std::stringstream query;
+std::ostringstream query;
 query << "INSERT INTO tb_admins \
               (login, passwd, \
               chg_conf, chg_password, chg_stat, \
@@ -386,9 +386,9 @@ if (CommitTransaction())
 return 0;
 }
 //-----------------------------------------------------------------------------
-int POSTGRESQL_STORE::DelAdmin(const string & login) const
+int POSTGRESQL_STORE::DelAdmin(const std::string & login) const
 {
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
 
 if (PQstatus(connection) != CONNECTION_OK)
     {
@@ -421,7 +421,7 @@ if (EscapeString(elogin))
     return -1;
     }
 
-std::stringstream query;
+std::ostringstream query;
 query << "DELETE FROM tb_admins WHERE login = '" << elogin << "'";
 
 result = PQexec(connection, query.str().c_str());