summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <Klaus (dot) Schmidinger (at) tvdr (dot) de>2010-01-31 15:42:00 +0100
committerKlaus Schmidinger <Klaus (dot) Schmidinger (at) tvdr (dot) de>2010-01-31 15:42:00 +0100
commit09a17d56e2a3f975a0467e8da4ca26c946b6ccf7 (patch)
tree4ca95499f117bf8bf0a51149bb85493d93ee111e /config.c
parent939081e274d0a9868e5ba9a7951666ad508afb96 (diff)
downloadvdr-patch-lnbsharing-09a17d56e2a3f975a0467e8da4ca26c946b6ccf7.tar.gz
vdr-patch-lnbsharing-09a17d56e2a3f975a0467e8da4ca26c946b6ccf7.tar.bz2
Version 1.7.12vdr-1.7.12
- Changed the EVCONTENTMASK_* macros to enums and changed "mask" to "group". - Updated the Estonian OSD texts (thanks to Arthur Konovalov). - The "Edit timer" menu can now set the folder for the recording from a list of folders stored in "folders.conf". - Updated the Italian OSD texts (thanks to Diego Pierotto). - If svdrphosts.conf contains only the address of the local host, the SVDRP port is opened only for the local host (thanks to Manuel Reimer). - Renamed 'runvdr' to 'runvdr.template' and no longer copying it to the BINDIR in 'make install' (thanks to Martin Dauskardt). - Added plain text error messages to log entries from cOsd::SetAreas() (suggested by Rolf Ahrenberg). - cPalette::ClosestColor() now treats fully transparent colors as "equal"; improved cDvbSpuBitmap::getMinBpp() (thanks to Matthieu Castet and Johann Friedrichs). - The new setup option "Miscellaneous/Channels wrap" controls whether the current channel wraps around the beginning or end of the channel list when zapping (thanks to Matti Lehtimäki). - Fixed determining the frame duration on channels where the PTS deltas jitter by +/-1 around 1800. - The PCR pid in generated PMTs is now set to the channel's PCR pid again. - Fixed determining the frame duration on channels where the PTS deltas jitter by +/-1 around 3600. - The PCR pid is now recorded for channels where this is different from the video PID. To facilitate this, the interfaces of cTransfer, cTransferControl, cRecorder and cReceiver have been modified, so that the PIDs are no longer given in separate parameters, but rather the whole channel is handed down for processing. The old constructor of cReceiver is still available, but it is recommended to plugin authors that they switch to the new interface as soon as possible. When replaying such a recording, the PCR packets are sent to PlayTsVideo() - The files "commands.conf" and "reccmd.conf" can now contain nested lists of commands. See vdr.5 for information about the new file format.
Diffstat (limited to 'config.c')
-rw-r--r--config.c236
1 files changed, 167 insertions, 69 deletions
diff --git a/config.c b/config.c
index 61de0f5..acdf4c4 100644
--- a/config.c
+++ b/config.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: config.c 2.6 2009/12/05 15:30:30 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)
@@ -118,20 +53,180 @@ bool cSVDRPhost::Parse(const char *s)
return result != 0 && (mask != 0 || addr.s_addr == 0);
}
+bool cSVDRPhost::IsLocalhost(void)
+{
+ return addr.s_addr == htonl(INADDR_LOOPBACK);
+}
+
bool cSVDRPhost::Accepts(in_addr_t Address)
{
return (Address & mask) == (addr.s_addr & mask);
}
-// --- cCommands -------------------------------------------------------------
+// --- cNestedItem -----------------------------------------------------------
+
+cNestedItem::cNestedItem(const char *Text, bool WithSubItems)
+{
+ text = strdup(Text ? Text : "");
+ subItems = WithSubItems ? new cList<cNestedItem> : NULL;
+}
+
+cNestedItem::~cNestedItem()
+{
+ delete subItems;
+ free(text);
+}
-cCommands Commands;
-cCommands RecordingCommands;
+int cNestedItem::Compare(const cListObject &ListObject) const
+{
+ return strcasecmp(text, ((cNestedItem *)&ListObject)->text);
+}
+
+void cNestedItem::AddSubItem(cNestedItem *Item)
+{
+ if (!subItems)
+ subItems = new cList<cNestedItem>;
+ if (Item)
+ subItems->Add(Item);
+}
+
+void cNestedItem::SetText(const char *Text)
+{
+ free(text);
+ text = strdup(Text ? Text : "");
+}
+
+void cNestedItem::SetSubItems(bool On)
+{
+ if (On && !subItems)
+ subItems = new cList<cNestedItem>;
+ else if (!On && subItems) {
+ delete subItems;
+ subItems = NULL;
+ }
+}
+
+// --- cNestedItemList -------------------------------------------------------
+
+cNestedItemList::cNestedItemList(void)
+{
+ fileName = NULL;
+}
+
+cNestedItemList::~cNestedItemList()
+{
+ free(fileName);
+}
+
+bool cNestedItemList::Parse(FILE *f, cList<cNestedItem> *List, int &Line)
+{
+ char *s;
+ cReadLine ReadLine;
+ while ((s = ReadLine.Read(f)) != NULL) {
+ Line++;
+ char *p = strchr(s, '#');
+ if (p)
+ *p = 0;
+ s = skipspace(stripspace(s));
+ if (!isempty(s)) {
+ p = s + strlen(s) - 1;
+ if (*p == '{') {
+ *p = 0;
+ stripspace(s);
+ cNestedItem *Item = new cNestedItem(s, true);
+ List->Add(Item);
+ if (!Parse(f, Item->SubItems(), Line))
+ return false;
+ }
+ else if (*s == '}')
+ break;
+ else
+ List->Add(new cNestedItem(s));
+ }
+ }
+ return true;
+}
+
+bool cNestedItemList::Write(FILE *f, cList<cNestedItem> *List, int Indent)
+{
+ for (cNestedItem *Item = List->First(); Item; Item = List->Next(Item)) {
+ if (Item->SubItems()) {
+ fprintf(f, "%*s%s {\n", Indent, "", Item->Text());
+ Write(f, Item->SubItems(), Indent + 2);
+ fprintf(f, "%*s}\n", Indent + 2, "");
+ }
+ else
+ fprintf(f, "%*s%s\n", Indent, "", Item->Text());
+ }
+ return true;
+}
+
+void cNestedItemList::Clear(void)
+{
+ free(fileName);
+ fileName = NULL;
+ cList<cNestedItem>::Clear();
+}
+
+bool cNestedItemList::Load(const char *FileName)
+{
+ cList<cNestedItem>::Clear();
+ if (FileName) {
+ free(fileName);
+ fileName = strdup(FileName);
+ }
+ bool result = false;
+ if (fileName && access(fileName, F_OK) == 0) {
+ isyslog("loading %s", fileName);
+ FILE *f = fopen(fileName, "r");
+ if (f) {
+ int Line = 0;
+ result = Parse(f, this, Line);
+ fclose(f);
+ }
+ else {
+ LOG_ERROR_STR(fileName);
+ result = false;
+ }
+ }
+ return result;
+}
+
+bool cNestedItemList::Save(void)
+{
+ bool result = true;
+ cSafeFile f(fileName);
+ if (f.Open()) {
+ result = Write(f, this);
+ if (!f.Close())
+ result = false;
+ }
+ else
+ result = false;
+ return result;
+}
+
+// --- Folders and Commands --------------------------------------------------
+
+cNestedItemList Folders;
+cNestedItemList Commands;
+cNestedItemList RecordingCommands;
// --- cSVDRPhosts -----------------------------------------------------------
cSVDRPhosts SVDRPhosts;
+bool cSVDRPhosts::LocalhostOnly(void)
+{
+ cSVDRPhost *h = First();
+ while (h) {
+ if (!h->IsLocalhost())
+ return false;
+ h = (cSVDRPhost *)h->Next();
+ }
+ return true;
+}
+
bool cSVDRPhosts::Acceptable(in_addr_t Address)
{
cSVDRPhost *h = First();
@@ -299,6 +394,7 @@ cSetup::cSetup(void)
CurrentDolby = 0;
InitialChannel = 0;
InitialVolume = -1;
+ ChannelsWrap = 0;
EmergencyExit = 1;
}
@@ -486,6 +582,7 @@ bool cSetup::Parse(const char *Name, const char *Value)
else if (!strcasecmp(Name, "CurrentDolby")) CurrentDolby = atoi(Value);
else if (!strcasecmp(Name, "InitialChannel")) InitialChannel = atoi(Value);
else if (!strcasecmp(Name, "InitialVolume")) InitialVolume = atoi(Value);
+ else if (!strcasecmp(Name, "ChannelsWrap")) ChannelsWrap = atoi(Value);
else if (!strcasecmp(Name, "EmergencyExit")) EmergencyExit = atoi(Value);
else
return false;
@@ -578,6 +675,7 @@ bool cSetup::Save(void)
Store("CurrentDolby", CurrentDolby);
Store("InitialChannel", InitialChannel);
Store("InitialVolume", InitialVolume);
+ Store("ChannelsWrap", ChannelsWrap);
Store("EmergencyExit", EmergencyExit);
Sort();