diff options
author | mrwastl <mrwastl@users.sourceforge.net> | 2010-05-04 21:03:19 +0200 |
---|---|---|
committer | mrwastl <mrwastl@users.sourceforge.net> | 2010-05-04 21:03:19 +0200 |
commit | 8a4168bd0d2e468604755398f18be1fba9046aa0 (patch) | |
tree | 56558e0517e3b63483a2813146563eaf0371c666 /alias.c | |
parent | 75ebec3efc4879fc8bee8a3ecfe71809d9fccefd (diff) | |
download | vdr-plugin-graphlcd-8a4168bd0d2e468604755398f18be1fba9046aa0.tar.gz vdr-plugin-graphlcd-8a4168bd0d2e468604755398f18be1fba9046aa0.tar.bz2 |
initial git upload, based on graphlcd-0.2.0-pre2
Diffstat (limited to 'alias.c')
-rw-r--r-- | alias.c | 73 |
1 files changed, 73 insertions, 0 deletions
@@ -0,0 +1,73 @@ +/* + * GraphLCD plugin for the Video Disk Recorder + * + * alias.c - alias class for converting channel id to its alias name + * + * This file is released under the GNU General Public License. Refer + * to the COPYING file distributed with this package. + * + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de> + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de> + */ + +#include <fstream> + +#include "alias.h" +#include "strfct.h" + +#include <vdr/tools.h> + +const char * kChannelAliasFileName = "channels.alias"; + +bool cChannelAliasList::Load(const std::string & CfgPath) +{ + std::fstream file; + char readLine[1000]; + std::string line; + std::string aliasFileName; + std::string::size_type pos; + std::string id; + std::string alias; + + aliasFileName = CfgPath + "/" + kChannelAliasFileName; + +#if (__GNUC__ < 3) + file.open(aliasFileName.c_str(), std::ios::in); +#else + file.open(aliasFileName.c_str(), std::ios_base::in); +#endif + if (!file.is_open()) + { + esyslog("graphlcd: Error opening channel alias file %s!", aliasFileName.c_str()); + return false; + } + + while (!file.eof()) + { + file.getline(readLine, 1000); + line = trim(readLine); + if (line.length() == 0) + continue; + if (line[0] == '#') + continue; + pos = line.find(":"); + if (pos == std::string::npos) + continue; + id = trim(line.substr(0, pos)); + alias = trim(line.substr(pos + 1)); + mAliases.insert(std::make_pair(id, alias)); + } + file.close(); + + return true; +} + +std::string cChannelAliasList::GetAlias(const std::string & ChannelID) const +{ + std::map<std::string, std::string>::const_iterator pos; + + pos = mAliases.find(ChannelID); + if (pos != mAliases.end()) + return pos->second; + return ""; +} |