diff options
author | methodus <methodus@web.de> | 2012-12-10 20:49:53 +0100 |
---|---|---|
committer | methodus <methodus@web.de> | 2012-12-10 20:49:53 +0100 |
commit | 7c5e5dac8eba1e6132582f7ff549fd04dc877ce1 (patch) | |
tree | 4f937c7a5eb686d25e44be178d0e7d6867456e1b /plugins/provider/vdrProvider | |
parent | b36c18930b3221fbc7cfea674472d77cdb466c98 (diff) | |
download | vdr-plugin-upnp-7c5e5dac8eba1e6132582f7ff549fd04dc877ce1.tar.gz vdr-plugin-upnp-7c5e5dac8eba1e6132582f7ff549fd04dc877ce1.tar.bz2 |
Ignoring signal SIGPIPE which might cause crashes
Diffstat (limited to 'plugins/provider/vdrProvider')
-rw-r--r-- | plugins/provider/vdrProvider/vdrProvider.cpp | 45 |
1 files changed, 10 insertions, 35 deletions
diff --git a/plugins/provider/vdrProvider/vdrProvider.cpp b/plugins/provider/vdrProvider/vdrProvider.cpp index c9b9a95..6b4c1b1 100644 --- a/plugins/provider/vdrProvider/vdrProvider.cpp +++ b/plugins/provider/vdrProvider/vdrProvider.cpp @@ -13,7 +13,6 @@ #include <vdr/plugin.h> #include <string> #include <sstream> -#include <fstream> #include <algorithm> #include <tools.h> #include <pwd.h> @@ -29,39 +28,17 @@ private: int from; int to; - bool Load(const string& filename) + bool Parse(const string& line) { - if (access(filename.c_str(), F_OK) == 0) { - isyslog("loading %s", filename.c_str()); - ifstream file; - file.open(filename.c_str(), ifstream::in); - if(!file.is_open()) - return false; - string line; int pos; - while(getline(file, line)){ - if(line.length() > 0 && line[0] != '#'){ - if((pos = line.find_first_of('-')) != string::npos){ - from = atoi(line.substr(0, pos).c_str()); - to = atoi(line.substr(pos+1).c_str()); - break; - } - } - } - if(to == 0) to = INT_MAX; + int pos = 0; + if((pos = line.find_first_of('-')) != string::npos){ + from = atoi(line.substr(0, pos).c_str()); + to = atoi(line.substr(pos+1).c_str()); return true; } return false; } - bool IsRootContainer(const string& uri){ - if(uri.find(GetRootContainer(), 0) != 0){ - isyslog("VdrProvider\tUri does not contain the root."); - return false; - } else { - return true; - } - } - int GetGroupByName(string name) { if(name.empty()) return -1; @@ -83,9 +60,7 @@ public: , from(0) , to(INT_MAX) { - stringstream file; - file << cMediaServer::GetInstance()->GetConfigDirectory() << "/vdrProvider.conf"; - Load(file.str()); + LoadConfigFile("vdrProvider.conf"); } virtual ~VdrProvider(){ @@ -99,7 +74,7 @@ public: } virtual StringList GetContainerEntries(const string& uri){ - if(!IsRootContainer(uri)) return StringList(); + if(!HasRootContainer(uri)) return StringList(); StringList list; int index; @@ -143,14 +118,14 @@ public: } virtual long GetContainerUpdateId(const string& uri){ - if(!IsRootContainer(uri)) return 0; + if(!HasRootContainer(uri)) return 0; // We now have containers. However, they do not support containerUpdateIDs separately. return (long)lastModified; } virtual bool GetMetadata(const string& uri, cMetadata& metadata){ - if(!IsRootContainer(uri)) return false; + if(!HasRootContainer(uri)) return false; if(!cUPnPResourceProvider::GetMetadata(uri, metadata)) return false; @@ -179,7 +154,7 @@ public: } virtual string GetHTTPUri(const string& uri, const string& currentIP, const string& pInfo){ - if(!IsRootContainer(uri)) return string(); + if(!HasRootContainer(uri)) return string(); int port = 3000; |