-//-----------------------------------------------------------------------------
-SETTINGS_IMPL::SETTINGS_IMPL()
- : SETTINGS(),
- strError(),
- modulesPath("/usr/lib/stg"),
- dirName(DIR_NUM),
- confDir("/etc/stargazer"),
- scriptsDir("/etc/stargazer"),
- rules("/etc/stargazer/rules"),
- logFile("/var/log/stargazer.log"),
- pidFile("/var/run/stargazer.pid"),
- monitorDir("/var/stargazer/monitoring"),
- monitoring(false),
- detailStatWritePeriod(dsPeriod_1_6),
- statWritePeriod(10),
- stgExecMsgKey(5555),
- executersNum(1),
- fullFee(false),
- dayFee(0),
- dayResetTraff(0),
- spreadFee(false),
- freeMbAllowInet(false),
- dayFeeIsLastDay(false),
- writeFreeMbTraffCost(false),
- showFeeInCash(true),
- messageTimeout(0),
- feeChargeType(0),
- reconnectOnTariffChange(false),
- modulesSettings(),
- storeModuleSettings(),
- logger(GetStgLogger())
+struct Error : public std::runtime_error
+{
+ explicit Error(const std::string& message) : runtime_error(message) {}
+};
+
+std::vector<std::string> toValues(const DOTCONFDocumentNode& node)
+{
+ std::vector<std::string> values;
+
+ size_t i = 0;
+ const char* value = NULL;
+ while ((value = node.getValue(i++)) != NULL)
+ values.push_back(value);
+
+ return values;
+}
+
+std::vector<ParamValue> toPVS(const DOTCONFDocumentNode& node)
+{
+ std::vector<ParamValue> pvs;
+
+ const DOTCONFDocumentNode* child = node.getChildNode();
+ while (child != NULL)
+ {
+ if (child->getName() == NULL)
+ continue;
+
+ if (child->getChildNode() == NULL)
+ pvs.push_back(ParamValue(child->getName(), toValues(*child)));
+ else
+ pvs.push_back(ParamValue(child->getName(), toValues(*child), toPVS(*child)));
+
+ child = child->getNextNode();
+ }
+
+ return pvs;
+}
+
+unsigned toPeriod(const char* value)
+{
+ if (value == NULL)
+ throw Error("No detail stat period value.");
+
+ std::string period(value);
+ if (period == "1")
+ return STG::dsPeriod_1;
+ else if (period == "1/2")
+ return STG::dsPeriod_1_2;
+ else if (period == "1/4")
+ return STG::dsPeriod_1_4;
+ else if (period == "1/6")
+ return STG::dsPeriod_1_6;
+
+ throw Error("Invalid detail stat period value: '" + period + "'. Should be one of '1', '1/2', '1/4' or '1/6'.");
+}
+
+void errorCallback(void* /*data*/, const char* buf)