Add ability to blacklist devices

This commit is contained in:
pixl
2020-07-04 00:10:44 -04:00
parent 2654f319c6
commit ef84577b9c
5 changed files with 60 additions and 2 deletions
+30
View File
@@ -31,6 +31,36 @@ Configuration::Configuration(const char *config_file)
throw e;
}
const Setting &root = cfg.getRoot();
try
{
auto& _blacklist = root.lookup("blacklist");
if(_blacklist.isArray() || _blacklist.isList())
{
int len = _blacklist.getLength();
for(int i = 0; i < len; i++)
{
if(!_blacklist[i].isNumber()) {
log_printf(WARN, "Line %d: blacklist must only contain "
"PIDs", _blacklist[i].getSourceLine());
if(_blacklist.isArray())
break;
if(_blacklist.isList())
continue;
}
blacklist.push_back((int)_blacklist[i]);
}
}
else
{
log_printf(WARN, "Line %d: blacklist must be an array or list, "
"ignnoring.", _blacklist.getSourceLine());
}
}
catch(const SettingNotFoundException &e)
{
}
Setting* _devices;
try { _devices = &root["devices"]; }