X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FProtocols%2FDVB%2FDVBConfigParser.cc;h=fa57d9f19a049c8abd7456c94c60dae4519e242c;hb=fd3a0e8ac95d1158e9ea661ddf9187b67c70169f;hp=aa45acb1a52c114334c869d2773c9f20e51595af;hpb=34199e3d9e56891d51d497fc2367d14258fa0c37;p=senf.git diff --git a/Socket/Protocols/DVB/DVBConfigParser.cc b/Socket/Protocols/DVB/DVBConfigParser.cc index aa45acb..fa57d9f 100644 --- a/Socket/Protocols/DVB/DVBConfigParser.cc +++ b/Socket/Protocols/DVB/DVBConfigParser.cc @@ -1,7 +1,7 @@ #include "DVBConfigParser.hh" #include -#include "../../../Utils/Exception.hh" - +#include "senf/Utils/Exception.hh" +#include "senf/Utils/Logger.hh" using namespace std; #define prefix_ @@ -82,27 +82,34 @@ prefix_ void senf::DVBConfigParser::initConfigFile(string configFilePath_){ } configFilePath_ = configPath; } - configFile.open( configFilePath_.c_str(), ios_base::in); + configFilePath = configFilePath_; + configFile.open( configFilePath.c_str(), ios_base::in); if(configFile.bad()) - SENF_THROW_SYSTEM_EXCEPTION("Could not read configfile: ") << configFilePath_ << "."; + SENF_LOG((senf::log::IMPORTANT) ("Could not open channels file"<< configFilePath << "." )); + configFile.close(); } prefix_ string senf::DVBConfigParser::getConfigLine(string channel) { string configLine; size_t pos; transform(channel.begin(), channel.end(), channel.begin(), ::toupper); - if(configFile.bad()) - SENF_THROW_SYSTEM_EXCEPTION("Could not read file."); + + configFile.open( configFilePath.c_str(), ios_base::in); + if(configFile.bad()) + SENF_THROW_SYSTEM_EXCEPTION("Could not read channels file: ") << configFilePath << "."; + while (configFile.good()){ getline( configFile, configLine ); + SENF_LOG((senf::log::NOTICE) ("configLine: " << configLine )); transform(configLine.begin(), configLine.end(), configLine.begin(), ::toupper); pos = configLine.find(channel); if(pos != string::npos && pos == 0){ // only first matching number should be interpreted as channel number - configFile.seekg(0); + configFile.close(); return configLine; // Line found! } } + configFile.close(); SENF_THROW_SYSTEM_EXCEPTION("Channel \"")<< channel << "\" not found!"; return channel; }