summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2011-11-06 21:20:58 +0200
committerVille Skyttä <ville.skytta@iki.fi>2011-11-06 21:20:58 +0200
commit984b776eefdd174e97d6df0a4379b0a434e1eb49 (patch)
tree06f8b17a54520b3477b8c6e9fdecde9c28eaa117
parent4a8a399f639c501fec3e5523e12b71d3cb0b5b9d (diff)
downloadvdr-plugin-muggle-984b776eefdd174e97d6df0a4379b0a434e1eb49.tar.gz
vdr-plugin-muggle-984b776eefdd174e97d6df0a4379b0a434e1eb49.tar.bz2
Fix build with VDR >= 1.7.12.
-rw-r--r--mg_menu.c66
-rw-r--r--mg_menu.h19
2 files changed, 85 insertions, 0 deletions
diff --git a/mg_menu.c b/mg_menu.c
index 6708659..9db9902 100644
--- a/mg_menu.c
+++ b/mg_menu.c
@@ -494,3 +494,69 @@ mgMenu::PlayingItem(void) const
else
return PlayerControl()->CurrentItem();
}
+
+#if VDRVERSNUM >= 10712
+// Borrowed from epgsearch
+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/mg_menu.h b/mg_menu.h
index 4319c76..030d657 100644
--- a/mg_menu.h
+++ b/mg_menu.h
@@ -24,7 +24,26 @@
void showmessage(int duration, const char *msg, ...);
+#if VDRVERSNUM >= 10712
+// Borrowed from epgsearch
+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> {};
+#else
class cCommands;
+#endif
class mgSelection;
class mgMenu;