-int RADIUS::ParseSettings()
-{
- try {
- m_config = STG::Config(m_settings);
- return 0;
- } catch (const std::runtime_error& ex) {
- m_logger("Failed to parse settings. %s", ex.what());
- return -1;
+ std::vector<std::pair<std::string, AttrValue>> res;
+ for (const auto& token : tokens)
+ {
+ const boost::char_separator<char> sp(" =");
+ const tokenizer tok(token, sp);
+
+ std::vector<std::string> keyValue;
+ for (const auto& t : tok)
+ keyValue.push_back(t);
+
+ if (keyValue.size() != 2)
+ {
+ m_logger("The '%s' attribute specification has an incorrect format: '%s'.", paramName.c_str(), token.c_str());
+ printfd(__FILE__, "The '%s' attribute specification has an incorrect format: '%s'.", paramName.c_str(), token.c_str());
+ return {};
+ }
+
+ auto type = AttrValue::Type::PARAM_NAME;
+ std::string valueName = keyValue[1];
+ if (valueName.front() == '\'' && valueName.back() == '\'')
+ {
+ type = AttrValue::Type::VALUE;
+ valueName.erase(0, 1);
+ valueName.erase(valueName.length() - 1, 1);
+ }
+ else if ((valueName.front() == '\'' && valueName.back() != '\'') || (valueName.front() != '\'' && valueName.back() == '\''))
+ {
+ m_logger("Error ParseRules: '%s' attribute parameter value is invalid.\n", paramName.c_str());
+ printfd(__FILE__, "Error ParseRules: '%s' attribute parameter value is invalid.\n", paramName.c_str());
+ return {};
+ }
+ res.emplace_back(keyValue[0], AttrValue{valueName, type});