diff options
author | Christian Wieninger <cwieninger@gmx.de> | 2010-02-01 18:21:01 +0100 |
---|---|---|
committer | Christian Wieninger <cwieninger@gmx.de> | 2010-02-01 18:21:01 +0100 |
commit | 8474ee1d7b137774dba43ecc1be23e86ae0fbb0a (patch) | |
tree | 74f6ff23bef916a33a9808de7f00f7e3598c7ead | |
parent | 89d6f5b1e1a9887e5cf873fc351ff464f44203fe (diff) | |
download | vdr-plugin-epgsearch-8474ee1d7b137774dba43ecc1be23e86ae0fbb0a.tar.gz vdr-plugin-epgsearch-8474ee1d7b137774dba43ecc1be23e86ae0fbb0a.tar.bz2 |
support for vdr-1.7.12
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | HISTORY.DE | 1 | ||||
-rw-r--r-- | epgsearchtools.c | 65 | ||||
-rw-r--r-- | epgsearchtools.h | 20 | ||||
-rw-r--r-- | varparser.h | 1 |
5 files changed, 88 insertions, 0 deletions
@@ -3,6 +3,7 @@ VDR Plugin 'epgsearch' Revision History 2010-xx-xx; Version 0.9.25 new: +- support for vdr-1.7.12 - there is now an official git repository for epgsearch, that contains the latest development. First usage: @@ -3,6 +3,7 @@ VDR Plugin 'epgsearch' Revision History 2010-xx-xx; Version 0.9.25 neu: +- Unterstützung für vdr-1.7.12 - Es gibt nun ein offizielles git repository für epgsearch, das die neueste Entwicklung enthält. Zuerst: diff --git a/epgsearchtools.c b/epgsearchtools.c index 14f0e14..af06f45 100644 --- a/epgsearchtools.c +++ b/epgsearchtools.c @@ -1131,3 +1131,68 @@ long getAddrFromString(const char* hostnameOrIp, struct sockaddr_in* addr) return 0; } } + +#if VDRVERSNUM >= 10712 +char *cCommand::result = NULL; + +cCommand::cCommand(void) +{ + title = command = NULL; + confirm = false; +} + +cCommand::~cCommand() +{ + free(title); + free(command); +} + +bool cCommand::Parse(const char *s) +{ + const char *p = strchr(s, ':'); + if (p) { + int l = p - s; + if (l > 0) { + title = MALLOC(char, l + 1); + stripspace(strn0cpy(title, s, l + 1)); + if (!isempty(title)) { + int l = strlen(title); + if (l > 1 && title[l - 1] == '?') { + confirm = true; + title[l - 1] = 0; + } + command = stripspace(strdup(skipspace(p + 1))); + return !isempty(command); + } + } + } + return false; +} + +const char *cCommand::Execute(const char *Parameters) +{ + free(result); + result = NULL; + cString cmdbuf; + if (Parameters) + cmdbuf = cString::sprintf("%s %s", command, Parameters); + const char *cmd = *cmdbuf ? *cmdbuf : command; + dsyslog("executing command '%s'", cmd); + cPipe p; + if (p.Open(cmd, "r")) { + int l = 0; + int c; + while ((c = fgetc(p)) != EOF) { + if (l % 20 == 0) + result = (char *)realloc(result, l + 21); + result[l++] = char(c); + } + if (result) + result[l] = 0; + p.Close(); + } + else + esyslog("ERROR: can't open pipe for command '%s'", cmd); + return result; +} +#endif diff --git a/epgsearchtools.h b/epgsearchtools.h index 17733ad..93f0aff 100644 --- a/epgsearchtools.h +++ b/epgsearchtools.h @@ -258,4 +258,24 @@ typedef std::basic_string<char,ignorecase_traits> icstring; // --- eTimerMod ------------------------------------------------------------- enum eTimerMod { tmNoChange=0, tmStartStop=1, tmFile=2, tmAuxEventID=4 }; +#if VDRVERSNUM >= 10712 +// --- cCommands ------------------------------------------------------------------- +class cCommand : public cListObject { +private: + char *title; + char *command; + bool confirm; + static char *result; +public: + cCommand(void); + virtual ~cCommand(); + bool Parse(const char *s); + const char *Title(void) { return title; } + bool Confirm(void) { return confirm; } + const char *Execute(const char *Parameters = NULL); + }; + +class cCommands : public cConfig<cCommand> {}; +#endif + #endif diff --git a/varparser.h b/varparser.h index 9d102e0..3a018bc 100644 --- a/varparser.h +++ b/varparser.h @@ -27,6 +27,7 @@ The project's page is at http://winni.vdr-developer.org/epgsearch #include <string> #include <vector> #include <vdr/config.h> +#include "epgsearchtools.h" using std::string; using std::vector; |