diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2010-01-31 12:59:50 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2010-01-31 12:59:50 +0100 |
commit | 86291b620532968421d9ad46a5276e1e9761570c (patch) | |
tree | e24fe972bf60a4e575c39b0e5ca43bc36fe52b64 /config.c | |
parent | 08899602322175a6cb080951c2ad0dcbf71446fa (diff) | |
download | vdr-86291b620532968421d9ad46a5276e1e9761570c.tar.gz vdr-86291b620532968421d9ad46a5276e1e9761570c.tar.bz2 |
The files "commands.conf" and "reccmd.conf" can now contain nested lists of commands1.7.12
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 79 |
1 files changed, 7 insertions, 72 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.c 2.9 2010/01/17 15:08:32 kls Exp $ + * $Id: config.c 2.10 2010/01/31 12:36:36 kls Exp $ */ #include "config.h" @@ -22,71 +22,6 @@ #define ChkDoublePlausibility(Variable, Default) { if (Variable < 0.00001) Variable = Default; } -// --- cCommand -------------------------------------------------------------- - -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; -} - // --- cSVDRPhost ------------------------------------------------------------ cSVDRPhost::cSVDRPhost(void) @@ -194,7 +129,8 @@ bool cNestedItemList::Parse(FILE *f, cList<cNestedItem> *List, int &Line) *p = 0; s = skipspace(stripspace(s)); if (!isempty(s)) { - if ((p = strchr(s, '{')) != NULL) { + p = s + strlen(s) - 1; + if (*p == '{') { *p = 0; stripspace(s); cNestedItem *Item = new cNestedItem(s, true); @@ -270,12 +206,11 @@ bool cNestedItemList::Save(void) return result; } -cNestedItemList Folders; - -// --- cCommands ------------------------------------------------------------- +// --- Folders and Commands -------------------------------------------------- -cCommands Commands; -cCommands RecordingCommands; +cNestedItemList Folders; +cNestedItemList Commands; +cNestedItemList RecordingCommands; // --- cSVDRPhosts ----------------------------------------------------------- |