6 //-----------------------------------------------------------------------------
 
   8 //-----------------------------------------------------------------------------
 
   9 int PARSER_GET_ADMINS::ParseStart(void *, const char *el, const char **)
 
  11 if (strcasecmp(el, "GetAdmins") == 0)
 
  17 //-----------------------------------------------------------------------------
 
  18 int PARSER_GET_ADMINS::ParseEnd(void *, const char *el)
 
  20 if (strcasecmp(el, "GetAdmins") == 0)
 
  27 //-----------------------------------------------------------------------------
 
  28 void PARSER_GET_ADMINS::CreateAnswer()
 
  30 const PRIV * priv = currAdmin->GetPriv();
 
  33     //answerList->clear();
 
  34     answerList->erase(answerList->begin(), answerList->end());
 
  36     answerList->push_back("<Error Result=\"Error. Access denied.\"/>");
 
  41 //answerList->clear();
 
  42 answerList->erase(answerList->begin(), answerList->end());
 
  44 answerList->push_back("<Admins>");
 
  46 int h = admins->OpenSearch();
 
  49 while (admins->SearchNext(h, &ac) == 0)
 
  51     //memcpy(&p, &ac.priv, sizeof(unsigned int));
 
  52     p = (ac.priv.userStat << 0) +
 
  53         (ac.priv.userConf << 2) +
 
  54         (ac.priv.userCash << 4) +
 
  55         (ac.priv.userPasswd << 6) +
 
  56         (ac.priv.userAddDel << 8) +
 
  57         (ac.priv.adminChg << 10) +
 
  58         (ac.priv.tariffChg << 12);
 
  59     strprintf(&s, "<admin login=\"%s\" priv=\"%d\"/>", ac.login.c_str(), p);
 
  60     answerList->push_back(s);
 
  62 admins->CloseSearch(h);
 
  63 answerList->push_back("</Admins>");
 
  65 //-----------------------------------------------------------------------------
 
  67 //-----------------------------------------------------------------------------
 
  69 //-----------------------------------------------------------------------------
 
  70 int PARSER_DEL_ADMIN::ParseStart(void *, const char *el, const char **attr)
 
  73 if (strcasecmp(el, "DelAdmin") == 0)
 
  80 //-----------------------------------------------------------------------------
 
  81 int PARSER_DEL_ADMIN::ParseEnd(void *, const char *el)
 
  83 if (strcasecmp(el, "DelAdmin") == 0)
 
  90 //-----------------------------------------------------------------------------
 
  91 void PARSER_DEL_ADMIN::CreateAnswer()
 
  93 //answerList->clear();
 
  94 answerList->erase(answerList->begin(), answerList->end());
 
  96 if (admins->Del(adminToDel, *currAdmin) == 0)
 
  98     answerList->push_back("<DelAdmin Result=\"Ok\"/>");
 
 103     strprintf(&s, "<DelAdmin Result=\"Error. %s\"/>", admins->GetStrError().c_str());
 
 104     answerList->push_back(s);
 
 107 //-----------------------------------------------------------------------------
 
 108 int PARSER_DEL_ADMIN::CheckAttr(const char **attr)
 
 110 /*  <DelAdmin login=\"admin\">
 
 111  *  attr[0] = "login" (word login)
 
 112  *  attr[1] = login, value of login
 
 115 if (strcasecmp(attr[0], "login") == 0 && attr[1] && !attr[2])
 
 121 //-----------------------------------------------------------------------------
 
 123 //-----------------------------------------------------------------------------
 
 124 int PARSER_ADD_ADMIN::ParseStart(void *, const char *el, const char **attr)
 
 126 if (strcasecmp(el, "AddAdmin") == 0)
 
 128     adminToAdd = attr[1];
 
 133 //-----------------------------------------------------------------------------
 
 134 int PARSER_ADD_ADMIN::ParseEnd(void *, const char *el)
 
 136 //answerList->clear();
 
 137 answerList->erase(answerList->begin(), answerList->end());
 
 139 if (strcasecmp(el, "AddAdmin") == 0)
 
 146 //-----------------------------------------------------------------------------
 
 147 void PARSER_ADD_ADMIN::CreateAnswer()
 
 149 //answerList->clear();
 
 150 answerList->erase(answerList->begin(), answerList->end());
 
 152 if (admins->Add(adminToAdd, *currAdmin) == 0)
 
 154     answerList->push_back("<AddAdmin Result=\"Ok\"/>");
 
 159     strprintf(&s, "<AddAdmin Result=\"Error. %s\"/>", admins->GetStrError().c_str());
 
 160     answerList->push_back(s);
 
 163 //-----------------------------------------------------------------------------
 
 164 //-----------------------------------------------------------------------------
 
 166 //-----------------------------------------------------------------------------
 
 167 int PARSER_CHG_ADMIN::ParseStart(void *, const char *el, const char **attr)
 
 169 if (strcasecmp(el, "ChgAdmin") == 0)
 
 171     for (int i = 0; i < 6; i+=2)
 
 173         printfd(__FILE__, "PARSER_CHG_ADMIN::attr[%d] = %s\n", i, attr[i]);
 
 177         if (strcasecmp(attr[i], "Login") == 0)
 
 183         if (strcasecmp(attr[i], "Priv") == 0)
 
 185             privAsString = attr[i + 1];
 
 189         if (strcasecmp(attr[i], "Password") == 0)
 
 191             password = attr[i + 1];
 
 200 //-----------------------------------------------------------------------------
 
 201 int PARSER_CHG_ADMIN::ParseEnd(void *, const char *el)
 
 203 if (strcasecmp(el, "ChgAdmin") == 0)
 
 210 //-----------------------------------------------------------------------------
 
 211 void PARSER_CHG_ADMIN::CreateAnswer()
 
 213 answerList->erase(answerList->begin(), answerList->end());
 
 217 if (!login.res_empty())
 
 220     //if (admins->FindAdmin(login.data()) != NULL)
 
 222         if (!password.res_empty())
 
 223             conf.password = password.data();
 
 225         if (!privAsString.res_empty())
 
 228             if (str2x(privAsString.data().c_str(), p) < 0)
 
 230                 strprintf(&s, "<ChgAdmin Result = \"Incorrect parameter Priv.\"/>" );
 
 231                 answerList->push_back(s);
 
 234             //memcpy(&conf.priv, &p, sizeof(conf.priv));
 
 235             conf.priv.userStat      = (p & 0x0003) >> 0x00; // 1+2
 
 236             conf.priv.userConf      = (p & 0x000C) >> 0x02; // 4+8
 
 237             conf.priv.userCash      = (p & 0x0030) >> 0x04; // 10+20
 
 238             conf.priv.userPasswd    = (p & 0x00C0) >> 0x06; // 40+80
 
 239             conf.priv.userAddDel    = (p & 0x0300) >> 0x08; // 100+200
 
 240             conf.priv.adminChg      = (p & 0x0C00) >> 0x0A; // 400+800
 
 241             conf.priv.tariffChg     = (p & 0x3000) >> 0x0C; // 1000+2000
 
 244         if (admins->Change(conf, *currAdmin) != 0)
 
 246             strprintf(&s, "<ChgAdmin Result = \"%s\"/>", admins->GetStrError().c_str());
 
 247             answerList->push_back(s);
 
 251             answerList->push_back("<ChgAdmin Result = \"Ok\"/>");
 
 255     //strprintf(&s, "<ChgAdmin Result = \"%s\"/>", admins->GetStrError().c_str());
 
 256     //answerList->push_back(s);
 
 261     answerList->push_back("<ChgAdmin Result = \"Incorrect parameter login.\"/>");
 
 264 //-----------------------------------------------------------------------------*/