]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/configuration/sgconfig/parser_admin.cpp
Lots of stylistic fixes.
[stg.git] / projects / stargazer / plugins / configuration / sgconfig / parser_admin.cpp
index 5bc68d2adf36ace7769e4e167de59a708239589a..d93b3448f013efa4d8d6223afa39b6e02c182f95 100644 (file)
@@ -37,7 +37,7 @@ if (!priv->adminChg)
     return;
     }
 
-string s;
+std::string s;
 //answerList->clear();
 answerList->erase(answerList->begin(), answerList->end());
 
@@ -45,17 +45,16 @@ answerList->push_back("<Admins>");
 ADMIN_CONF ac;
 int h = admins->OpenSearch();
 
-unsigned int p;
 while (admins->SearchNext(h, &ac) == 0)
     {
     //memcpy(&p, &ac.priv, sizeof(unsigned int));
-    p = (ac.priv.userStat << 0) +
-        (ac.priv.userConf << 2) +
-        (ac.priv.userCash << 4) +
-        (ac.priv.userPasswd << 6) +
-        (ac.priv.userAddDel << 8) +
-        (ac.priv.adminChg << 10) +
-        (ac.priv.tariffChg << 12);
+    unsigned int p = (ac.priv.userStat << 0) +
+                     (ac.priv.userConf << 2) +
+                     (ac.priv.userCash << 4) +
+                     (ac.priv.userPasswd << 6) +
+                     (ac.priv.userAddDel << 8) +
+                     (ac.priv.adminChg << 10) +
+                     (ac.priv.tariffChg << 12);
     strprintf(&s, "<admin login=\"%s\" priv=\"%d\"/>", ac.login.c_str(), p);
     answerList->push_back(s);
     }
@@ -99,26 +98,12 @@ if (admins->Del(adminToDel, currAdmin) == 0)
     }
 else
     {
-    string s;
+    std::string s;
     strprintf(&s, "<DelAdmin Result=\"Error. %s\"/>", admins->GetStrError().c_str());
     answerList->push_back(s);
     }
 }
 //-----------------------------------------------------------------------------
-int PARSER_DEL_ADMIN::CheckAttr(const char **attr)
-{
-/*  <DelAdmin login=\"admin\">
- *  attr[0] = "login" (word login)
- *  attr[1] = login, value of login
- *  attr[2] = NULL                  */
-
-if (strcasecmp(attr[0], "login") == 0 && attr[1] && !attr[2])
-    {
-    return 0;
-    }
-return -1;
-}
-//-----------------------------------------------------------------------------
 //  ADD ADMIN
 //-----------------------------------------------------------------------------
 int PARSER_ADD_ADMIN::ParseStart(void *, const char *el, const char **attr)
@@ -155,7 +140,7 @@ if (admins->Add(adminToAdd, currAdmin) == 0)
     }
 else
     {
-    string s;
+    std::string s;
     strprintf(&s, "<AddAdmin Result=\"Error. %s\"/>", admins->GetStrError().c_str());
     answerList->push_back(s);
     }
@@ -213,11 +198,11 @@ void PARSER_CHG_ADMIN::CreateAnswer()
 answerList->erase(answerList->begin(), answerList->end());
 
 
-if (!login.res_empty())
+if (!login.empty())
     {
     ADMIN * origAdmin = NULL;
 
-    if (admins->Find(login, &origAdmin))
+    if (admins->Find(login.data(), &origAdmin))
         {
         answerList->push_back(std::string("<ChgAdmin Result = \"Admin '") + login.data() + "' is not found.\"/>");
         return;
@@ -225,10 +210,10 @@ if (!login.res_empty())
 
     ADMIN_CONF conf(origAdmin->GetConf());
 
-    if (!password.res_empty())
+    if (!password.empty())
         conf.password = password.data();
 
-    if (!privAsString.res_empty())
+    if (!privAsString.empty())
         {
         int p = 0;
         if (str2x(privAsString.data().c_str(), p) < 0)
@@ -242,7 +227,7 @@ if (!login.res_empty())
 
     if (admins->Change(conf, currAdmin) != 0)
         {
-        string s;
+        std::string s;
         strprintf(&s, "<ChgAdmin Result = \"%s\"/>", admins->GetStrError().c_str());
         answerList->push_back(s);
         }