}
//-----------------------------------------------------------------------------
MYSQL_STORE_SETTINGS::MYSQL_STORE_SETTINGS()
- : settings(NULL),
- errorStr(),
- dbUser(),
- dbPass(),
- dbName(),
- dbHost(),
- schemaVersion(0)
+ : settings(NULL)
{
}
//-----------------------------------------------------------------------------
-int MYSQL_STORE_SETTINGS::ParseParam(const std::vector<PARAM_VALUE> & moduleParams,
- const std::string & name, std::string & result)
+int MYSQL_STORE_SETTINGS::ParseParam(const std::vector<PARAM_VALUE> & moduleParams,
+ const std::string & name, std::string & result)
{
PARAM_VALUE pv;
pv.param = name;
std::vector<PARAM_VALUE>::const_iterator pvi;
pvi = find(moduleParams.begin(), moduleParams.end(), pv);
-if (pvi == moduleParams.end())
+if (pvi == moduleParams.end() || pvi->value.empty())
{
errorStr = "Parameter \'" + name + "\' not found.";
return -1;
}
-
+
result = pvi->value[0];
return 0;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
MYSQL_STORE::MYSQL_STORE()
- : errorStr(),
- version("mysql_store v.0.67"),
- storeSettings(),
- settings(),
+ : version("mysql_store v.0.67"),
+ schemaVersion(0),
logger(GetPluginLogger(GetStgLogger(), "store_mysql"))
{
}
memset(adminPass, 0, sizeof(adminPass));
BLOWFISH_CTX ctx;
-EnDecodeInit(adm_enc_passwd, strlen(adm_enc_passwd), &ctx);
+InitContext(adm_enc_passwd, strlen(adm_enc_passwd), &ctx);
strncpy(adminPass, ac.password.c_str(), ADM_PASSWD_LEN);
adminPass[ADM_PASSWD_LEN - 1] = 0;
for (int i = 0; i < ADM_PASSWD_LEN/8; i++)
{
- EncodeString(pass + 8*i, adminPass + 8*i, &ctx);
+ EncryptBlock(pass + 8*i, adminPass + 8*i, &ctx);
}
pass[ADM_PASSWD_LEN - 1] = 0;
if (passwordE[0] != 0)
{
Decode21(pass, passwordE);
- EnDecodeInit(adm_enc_passwd, strlen(adm_enc_passwd), &ctx);
+ InitContext(adm_enc_passwd, strlen(adm_enc_passwd), &ctx);
for (int i = 0; i < ADM_PASSWD_LEN/8; i++)
{
- DecodeString(password + 8*i, pass + 8*i, &ctx);
+ DecryptBlock(password + 8*i, pass + 8*i, &ctx);
}
}
else
return -1;
}
-if (!strcasecmp(str.c_str(), "up"))
- td->tariffConf.traffType = TRAFF_UP;
-else
- if (!strcasecmp(str.c_str(), "down"))
- td->tariffConf.traffType = TRAFF_DOWN;
- else
- if (!strcasecmp(str.c_str(), "up+down"))
- td->tariffConf.traffType = TRAFF_UP_DOWN;
- else
- if (!strcasecmp(str.c_str(), "max"))
- td->tariffConf.traffType = TRAFF_MAX;
- else
- {
- mysql_free_result(res);
- errorStr = "Cannot read tariff " + tariffName + ". Parameter TraffType incorrect";
- mysql_close(sock);
- return -1;
- }
+td->tariffConf.traffType = TARIFF::StringToTraffType(str);
if (schemaVersion > 0)
{
strprintf(¶m, " Free=%f,", td.tariffConf.free);
res += param;
-switch (td.tariffConf.traffType)
- {
- case TRAFF_UP:
- res += " TraffType='up'";
- break;
- case TRAFF_DOWN:
- res += " TraffType='down'";
- break;
- case TRAFF_UP_DOWN:
- res += " TraffType='up+down'";
- break;
- case TRAFF_MAX:
- res += " TraffType='max'";
- break;
- }
+res += " TraffType='" + TARIFF::TraffTypeToString(td.tariffConf.traffType) + "'";
if (schemaVersion > 0)
res += ", Period='" + TARIFF::PeriodToString(td.tariffConf.period) + "'";