vdr  1.7.27
config.c
Go to the documentation of this file.
00001 /*
00002  * config.c: Configuration file handling
00003  *
00004  * See the main source file 'vdr.c' for copyright information and
00005  * how to reach the author.
00006  *
00007  * $Id: config.c 2.20 2012/02/29 10:15:54 kls Exp $
00008  */
00009 
00010 #include "config.h"
00011 #include <ctype.h>
00012 #include <stdlib.h>
00013 #include "device.h"
00014 #include "i18n.h"
00015 #include "interface.h"
00016 #include "plugin.h"
00017 #include "recording.h"
00018 
00019 // IMPORTANT NOTE: in the 'sscanf()' calls there is a blank after the '%d'
00020 // format characters in order to allow any number of blanks after a numeric
00021 // value!
00022 
00023 #define ChkDoublePlausibility(Variable, Default) { if (Variable < 0.00001) Variable = Default; }
00024 
00025 // --- cSVDRPhost ------------------------------------------------------------
00026 
00027 cSVDRPhost::cSVDRPhost(void)
00028 {
00029   addr.s_addr = 0;
00030   mask = 0;
00031 }
00032 
00033 bool cSVDRPhost::Parse(const char *s)
00034 {
00035   mask = 0xFFFFFFFF;
00036   const char *p = strchr(s, '/');
00037   if (p) {
00038      char *error = NULL;
00039      int m = strtoul(p + 1, &error, 10);
00040      if (error && *error && !isspace(*error) || m > 32)
00041         return false;
00042      *(char *)p = 0; // yes, we know it's 'const' - will be restored!
00043      if (m == 0)
00044         mask = 0;
00045      else {
00046         mask <<= (32 - m);
00047         mask = htonl(mask);
00048         }
00049      }
00050   int result = inet_aton(s, &addr);
00051   if (p)
00052      *(char *)p = '/'; // there it is again
00053   return result != 0 && (mask != 0 || addr.s_addr == 0);
00054 }
00055 
00056 bool cSVDRPhost::IsLocalhost(void)
00057 {
00058   return addr.s_addr == htonl(INADDR_LOOPBACK);
00059 }
00060 
00061 bool cSVDRPhost::Accepts(in_addr_t Address)
00062 {
00063   return (Address & mask) == (addr.s_addr & mask);
00064 }
00065 
00066 // --- cSatCableNumbers ------------------------------------------------------
00067 
00068 cSatCableNumbers::cSatCableNumbers(int Size, const char *s)
00069 {
00070   size = Size;
00071   array = MALLOC(int, size);
00072   FromString(s);
00073 }
00074 
00075 cSatCableNumbers::~cSatCableNumbers()
00076 {
00077   free(array);
00078 }
00079 
00080 bool cSatCableNumbers::FromString(const char *s)
00081 {
00082   char *t;
00083   int i = 0;
00084   const char *p = s;
00085   while (p && *p) {
00086         int n = strtol(p, &t, 10);
00087         if (t != p) {
00088            if (i < size)
00089               array[i++] = n;
00090            else {
00091               esyslog("ERROR: too many sat cable numbers in '%s'", s);
00092               return false;
00093               }
00094            }
00095         else {
00096            esyslog("ERROR: invalid sat cable number in '%s'", s);
00097            return false;
00098            }
00099         p = skipspace(t);
00100         }
00101   for ( ; i < size; i++)
00102       array[i] = 0;
00103   return true;
00104 }
00105 
00106 cString cSatCableNumbers::ToString(void)
00107 {
00108   cString s("");
00109   for (int i = 0; i < size; i++) {
00110       s = cString::sprintf("%s%d ", *s, array[i]);
00111       }
00112   return s;
00113 }
00114 
00115 int cSatCableNumbers::FirstDeviceIndex(int DeviceIndex) const
00116 {
00117   if (0 <= DeviceIndex && DeviceIndex < size) {
00118      if (int CableNr = array[DeviceIndex]) {
00119         for (int i = 0; i < size; i++) {
00120             if (i < DeviceIndex && array[i] == CableNr)
00121                return i;
00122             }
00123         }
00124      }
00125   return -1;
00126 }
00127 
00128 // --- cNestedItem -----------------------------------------------------------
00129 
00130 cNestedItem::cNestedItem(const char *Text, bool WithSubItems)
00131 {
00132   text = strdup(Text ? Text : "");
00133   subItems = WithSubItems ? new cList<cNestedItem> : NULL;
00134 }
00135 
00136 cNestedItem::~cNestedItem()
00137 {
00138   delete subItems;
00139   free(text);
00140 }
00141 
00142 int cNestedItem::Compare(const cListObject &ListObject) const
00143 {
00144   return strcasecmp(text, ((cNestedItem *)&ListObject)->text);
00145 }
00146 
00147 void cNestedItem::AddSubItem(cNestedItem *Item)
00148 {
00149   if (!subItems)
00150      subItems = new cList<cNestedItem>;
00151   if (Item)
00152      subItems->Add(Item);
00153 }
00154 
00155 void cNestedItem::SetText(const char *Text)
00156 {
00157   free(text);
00158   text = strdup(Text ? Text : "");
00159 }
00160 
00161 void cNestedItem::SetSubItems(bool On)
00162 {
00163   if (On && !subItems)
00164      subItems = new cList<cNestedItem>;
00165   else if (!On && subItems) {
00166      delete subItems;
00167      subItems = NULL;
00168      }
00169 }
00170 
00171 // --- cNestedItemList -------------------------------------------------------
00172 
00173 cNestedItemList::cNestedItemList(void)
00174 {
00175   fileName = NULL;
00176 }
00177 
00178 cNestedItemList::~cNestedItemList()
00179 {
00180   free(fileName);
00181 }
00182 
00183 bool cNestedItemList::Parse(FILE *f, cList<cNestedItem> *List, int &Line)
00184 {
00185   char *s;
00186   cReadLine ReadLine;
00187   while ((s = ReadLine.Read(f)) != NULL) {
00188         Line++;
00189         char *p = strchr(s, '#');
00190         if (p)
00191            *p = 0;
00192         s = skipspace(stripspace(s));
00193         if (!isempty(s)) {
00194            p = s + strlen(s) - 1;
00195            if (*p == '{') {
00196               *p = 0;
00197               stripspace(s);
00198               cNestedItem *Item = new cNestedItem(s, true);
00199               List->Add(Item);
00200               if (!Parse(f, Item->SubItems(), Line))
00201                  return false;
00202               }
00203            else if (*s == '}')
00204               break;
00205            else
00206               List->Add(new cNestedItem(s));
00207            }
00208         }
00209   return true;
00210 }
00211 
00212 bool cNestedItemList::Write(FILE *f, cList<cNestedItem> *List, int Indent)
00213 {
00214   for (cNestedItem *Item = List->First(); Item; Item = List->Next(Item)) {
00215       if (Item->SubItems()) {
00216          fprintf(f, "%*s%s {\n", Indent, "", Item->Text());
00217          Write(f, Item->SubItems(), Indent + 2);
00218          fprintf(f, "%*s}\n", Indent + 2, "");
00219          }
00220       else
00221          fprintf(f, "%*s%s\n", Indent, "", Item->Text());
00222       }
00223   return true;
00224 }
00225 
00226 void cNestedItemList::Clear(void)
00227 {
00228   free(fileName);
00229   fileName = NULL;
00230   cList<cNestedItem>::Clear();
00231 }
00232 
00233 bool cNestedItemList::Load(const char *FileName)
00234 {
00235   cList<cNestedItem>::Clear();
00236   if (FileName) {
00237      free(fileName);
00238      fileName = strdup(FileName);
00239      }
00240   bool result = false;
00241   if (fileName && access(fileName, F_OK) == 0) {
00242      isyslog("loading %s", fileName);
00243      FILE *f = fopen(fileName, "r");
00244      if (f) {
00245         int Line = 0;
00246         result = Parse(f, this, Line);
00247         fclose(f);
00248         }
00249      else {
00250         LOG_ERROR_STR(fileName);
00251         result = false;
00252         }
00253      }
00254   return result;
00255 }
00256 
00257 bool cNestedItemList::Save(void)
00258 {
00259   bool result = true;
00260   cSafeFile f(fileName);
00261   if (f.Open()) {
00262      result = Write(f, this);
00263      if (!f.Close())
00264         result = false;
00265      }
00266   else
00267      result = false;
00268   return result;
00269 }
00270 
00271 // --- Folders and Commands --------------------------------------------------
00272 
00273 cNestedItemList Folders;
00274 cNestedItemList Commands;
00275 cNestedItemList RecordingCommands;
00276 cNestedItemList TimerCommands;
00277 
00278 // --- cSVDRPhosts -----------------------------------------------------------
00279 
00280 cSVDRPhosts SVDRPhosts;
00281 
00282 bool cSVDRPhosts::LocalhostOnly(void)
00283 {
00284   cSVDRPhost *h = First();
00285   while (h) {
00286         if (!h->IsLocalhost())
00287            return false;
00288         h = (cSVDRPhost *)h->Next();
00289         }
00290   return true;
00291 }
00292 
00293 bool cSVDRPhosts::Acceptable(in_addr_t Address)
00294 {
00295   cSVDRPhost *h = First();
00296   while (h) {
00297         if (h->Accepts(Address))
00298            return true;
00299         h = (cSVDRPhost *)h->Next();
00300         }
00301   return false;
00302 }
00303 
00304 // --- cSetupLine ------------------------------------------------------------
00305 
00306 cSetupLine::cSetupLine(void)
00307 {
00308   plugin = name = value = NULL;
00309 }
00310 
00311 cSetupLine::cSetupLine(const char *Name, const char *Value, const char *Plugin)
00312 {
00313   name = strdup(Name);
00314   value = strdup(Value);
00315   plugin = Plugin ? strdup(Plugin) : NULL;
00316 }
00317 
00318 cSetupLine::~cSetupLine()
00319 {
00320   free(plugin);
00321   free(name);
00322   free(value);
00323 }
00324 
00325 int cSetupLine::Compare(const cListObject &ListObject) const
00326 {
00327   const cSetupLine *sl = (cSetupLine *)&ListObject;
00328   if (!plugin && !sl->plugin)
00329      return strcasecmp(name, sl->name);
00330   if (!plugin)
00331      return -1;
00332   if (!sl->plugin)
00333      return 1;
00334   int result = strcasecmp(plugin, sl->plugin);
00335   if (result == 0)
00336      result = strcasecmp(name, sl->name);
00337   return result;
00338 }
00339 
00340 bool cSetupLine::Parse(char *s)
00341 {
00342   char *p = strchr(s, '=');
00343   if (p) {
00344      *p = 0;
00345      char *Name  = compactspace(s);
00346      char *Value = compactspace(p + 1);
00347      if (*Name) { // value may be an empty string
00348         p = strchr(Name, '.');
00349         if (p) {
00350            *p = 0;
00351            char *Plugin = compactspace(Name);
00352            Name = compactspace(p + 1);
00353            if (!(*Plugin && *Name))
00354               return false;
00355            plugin = strdup(Plugin);
00356            }
00357         name = strdup(Name);
00358         value = strdup(Value);
00359         return true;
00360         }
00361      }
00362   return false;
00363 }
00364 
00365 bool cSetupLine::Save(FILE *f)
00366 {
00367   return fprintf(f, "%s%s%s = %s\n", plugin ? plugin : "", plugin ? "." : "", name, value) > 0;
00368 }
00369 
00370 // --- cSetup ----------------------------------------------------------------
00371 
00372 cSetup Setup;
00373 
00374 cSetup::cSetup(void)
00375 {
00376   strcpy(OSDLanguage, ""); // default is taken from environment
00377   strcpy(OSDSkin, "sttng");
00378   strcpy(OSDTheme, "default");
00379   PrimaryDVB = 1;
00380   ShowInfoOnChSwitch = 1;
00381   TimeoutRequChInfo = 1;
00382   MenuScrollPage = 1;
00383   MenuScrollWrap = 0;
00384   MenuKeyCloses = 0;
00385   MarkInstantRecord = 1;
00386   strcpy(NameInstantRecord, "TITLE EPISODE");
00387   InstantRecordTime = 180;
00388   LnbSLOF    = 11700;
00389   LnbFrequLo =  9750;
00390   LnbFrequHi = 10600;
00391   DiSEqC = 0;
00392   SetSystemTime = 0;
00393   TimeSource = 0;
00394   TimeTransponder = 0;
00395   MarginStart = 2;
00396   MarginStop = 10;
00397   AudioLanguages[0] = -1;
00398   DisplaySubtitles = 0;
00399   SupportTeletext = 1;
00400   SubtitleLanguages[0] = -1;
00401   SubtitleOffset = 0;
00402   SubtitleFgTransparency = 0;
00403   SubtitleBgTransparency = 0;
00404   EPGLanguages[0] = -1;
00405   EPGScanTimeout = 5;
00406   EPGBugfixLevel = 3;
00407   EPGLinger = 0;
00408   SVDRPTimeout = 300;
00409   ZapTimeout = 3;
00410   ChannelEntryTimeout = 1000;
00411   DefaultPriority = 50;
00412   DefaultLifetime = MAXLIFETIME;
00413   PauseKeyHandling = 2;
00414   PausePriority = 10;
00415   PauseLifetime = 1;
00416   UseSubtitle = 1;
00417   UseVps = 0;
00418   VpsMargin = 120;
00419   RecordingDirs = 1;
00420   FoldersInTimerMenu = 1;
00421   NumberKeysForChars = 1;
00422   VideoDisplayFormat = 1;
00423   VideoFormat = 0;
00424   UpdateChannels = 5;
00425   UseDolbyDigital = 1;
00426   ChannelInfoPos = 0;
00427   ChannelInfoTime = 5;
00428   OSDLeftP = 0.08;
00429   OSDTopP = 0.08;
00430   OSDWidthP = 0.87;
00431   OSDHeightP = 0.84;
00432   OSDLeft = 54;
00433   OSDTop = 45;
00434   OSDWidth = 624;
00435   OSDHeight = 486;
00436   OSDAspect = 1.0;
00437   OSDMessageTime = 1;
00438   UseSmallFont = 1;
00439   AntiAlias = 1;
00440   strcpy(FontOsd, DefaultFontOsd);
00441   strcpy(FontSml, DefaultFontSml);
00442   strcpy(FontFix, DefaultFontFix);
00443   FontOsdSizeP = 0.038;
00444   FontSmlSizeP = 0.035;
00445   FontFixSizeP = 0.031;
00446   FontOsdSize = 22;
00447   FontSmlSize = 18;
00448   FontFixSize = 20;
00449   MaxVideoFileSize = MAXVIDEOFILESIZEDEFAULT;
00450   MaxRecordingSize = DEFAULTRECORDINGSIZE;
00451   SplitEditedFiles = 0;
00452   DelTimeshiftRec = 0;
00453   HardLinkCutter = 0;
00454   MinEventTimeout = 30;
00455   MinUserInactivity = 300;
00456   NextWakeupTime = 0;
00457   MultiSpeedMode = 0;
00458   ShowReplayMode = 0;
00459   ShowRemainingTime = 0;
00460   ResumeID = 0;
00461   JumpPlay = 0;
00462   PlayJump = 0;
00463   PauseLastMark = 0;
00464   CurrentChannel = -1;
00465   CurrentVolume = MAXVOLUME;
00466   CurrentDolby = 0;
00467   InitialChannel = "";
00468   DeviceBondings = "";
00469   InitialVolume = -1;
00470   ChannelsWrap = 0;
00471   EmergencyExit = 1;
00472 }
00473 
00474 cSetup& cSetup::operator= (const cSetup &s)
00475 {
00476   memcpy(&__BeginData__, &s.__BeginData__, (char *)&s.__EndData__ - (char *)&s.__BeginData__);
00477   InitialChannel = s.InitialChannel;
00478   DeviceBondings = s.DeviceBondings;
00479   return *this;
00480 }
00481 
00482 cSetupLine *cSetup::Get(const char *Name, const char *Plugin)
00483 {
00484   for (cSetupLine *l = First(); l; l = Next(l)) {
00485       if ((l->Plugin() == NULL) == (Plugin == NULL)) {
00486          if ((!Plugin || strcasecmp(l->Plugin(), Plugin) == 0) && strcasecmp(l->Name(), Name) == 0)
00487             return l;
00488          }
00489       }
00490   return NULL;
00491 }
00492 
00493 void cSetup::Store(const char *Name, const char *Value, const char *Plugin, bool AllowMultiple)
00494 {
00495   if (Name && *Name) {
00496      cSetupLine *l = Get(Name, Plugin);
00497      if (l && !AllowMultiple)
00498         Del(l);
00499      if (Value)
00500         Add(new cSetupLine(Name, Value, Plugin));
00501      }
00502 }
00503 
00504 void cSetup::Store(const char *Name, int Value, const char *Plugin)
00505 {
00506   Store(Name, cString::sprintf("%d", Value), Plugin);
00507 }
00508 
00509 void cSetup::Store(const char *Name, double &Value, const char *Plugin)
00510 {
00511   Store(Name, cString::sprintf("%f", Value), Plugin);
00512 }
00513 
00514 bool cSetup::Load(const char *FileName)
00515 {
00516   if (cConfig<cSetupLine>::Load(FileName, true)) {
00517      bool result = true;
00518      for (cSetupLine *l = First(); l; l = Next(l)) {
00519          bool error = false;
00520          if (l->Plugin()) {
00521             cPlugin *p = cPluginManager::GetPlugin(l->Plugin());
00522             if (p && !p->SetupParse(l->Name(), l->Value()))
00523                error = true;
00524             }
00525          else {
00526             if (!Parse(l->Name(), l->Value()))
00527                error = true;
00528             }
00529          if (error) {
00530             esyslog("ERROR: unknown config parameter: %s%s%s = %s", l->Plugin() ? l->Plugin() : "", l->Plugin() ? "." : "", l->Name(), l->Value());
00531             result = false;
00532             }
00533          }
00534      return result;
00535      }
00536   return false;
00537 }
00538 
00539 void cSetup::StoreLanguages(const char *Name, int *Values)
00540 {
00541   char buffer[I18nLanguages()->Size() * 4];
00542   char *q = buffer;
00543   for (int i = 0; i < I18nLanguages()->Size(); i++) {
00544       if (Values[i] < 0)
00545          break;
00546       const char *s = I18nLanguageCode(Values[i]);
00547       if (s) {
00548          if (q > buffer)
00549             *q++ = ' ';
00550          strncpy(q, s, 3);
00551          q += 3;
00552          }
00553       }
00554   *q = 0;
00555   Store(Name, buffer);
00556 }
00557 
00558 bool cSetup::ParseLanguages(const char *Value, int *Values)
00559 {
00560   int n = 0;
00561   while (Value && *Value && n < I18nLanguages()->Size()) {
00562         char buffer[4];
00563         strn0cpy(buffer, Value, sizeof(buffer));
00564         int i = I18nLanguageIndex(buffer);
00565         if (i >= 0)
00566            Values[n++] = i;
00567         if ((Value = strchr(Value, ' ')) != NULL)
00568            Value++;
00569         }
00570   Values[n] = -1;
00571   return true;
00572 }
00573 
00574 bool cSetup::Parse(const char *Name, const char *Value)
00575 {
00576   if      (!strcasecmp(Name, "OSDLanguage"))       { strn0cpy(OSDLanguage, Value, sizeof(OSDLanguage)); I18nSetLocale(OSDLanguage); }
00577   else if (!strcasecmp(Name, "OSDSkin"))             Utf8Strn0Cpy(OSDSkin, Value, MaxSkinName);
00578   else if (!strcasecmp(Name, "OSDTheme"))            Utf8Strn0Cpy(OSDTheme, Value, MaxThemeName);
00579   else if (!strcasecmp(Name, "PrimaryDVB"))          PrimaryDVB         = atoi(Value);
00580   else if (!strcasecmp(Name, "ShowInfoOnChSwitch"))  ShowInfoOnChSwitch = atoi(Value);
00581   else if (!strcasecmp(Name, "TimeoutRequChInfo"))   TimeoutRequChInfo  = atoi(Value);
00582   else if (!strcasecmp(Name, "MenuScrollPage"))      MenuScrollPage     = atoi(Value);
00583   else if (!strcasecmp(Name, "MenuScrollWrap"))      MenuScrollWrap     = atoi(Value);
00584   else if (!strcasecmp(Name, "MenuKeyCloses"))       MenuKeyCloses      = atoi(Value);
00585   else if (!strcasecmp(Name, "MarkInstantRecord"))   MarkInstantRecord  = atoi(Value);
00586   else if (!strcasecmp(Name, "NameInstantRecord"))   Utf8Strn0Cpy(NameInstantRecord, Value, MaxFileName);
00587   else if (!strcasecmp(Name, "InstantRecordTime"))   InstantRecordTime  = atoi(Value);
00588   else if (!strcasecmp(Name, "LnbSLOF"))             LnbSLOF            = atoi(Value);
00589   else if (!strcasecmp(Name, "LnbFrequLo"))          LnbFrequLo         = atoi(Value);
00590   else if (!strcasecmp(Name, "LnbFrequHi"))          LnbFrequHi         = atoi(Value);
00591   else if (!strcasecmp(Name, "DiSEqC"))              DiSEqC             = atoi(Value);
00592   else if (!strcasecmp(Name, "SetSystemTime"))       SetSystemTime      = atoi(Value);
00593   else if (!strcasecmp(Name, "TimeSource"))          TimeSource         = cSource::FromString(Value);
00594   else if (!strcasecmp(Name, "TimeTransponder"))     TimeTransponder    = atoi(Value);
00595   else if (!strcasecmp(Name, "MarginStart"))         MarginStart        = atoi(Value);
00596   else if (!strcasecmp(Name, "MarginStop"))          MarginStop         = atoi(Value);
00597   else if (!strcasecmp(Name, "AudioLanguages"))      return ParseLanguages(Value, AudioLanguages);
00598   else if (!strcasecmp(Name, "DisplaySubtitles"))    DisplaySubtitles   = atoi(Value);
00599   else if (!strcasecmp(Name, "SupportTeletext"))     SupportTeletext    = atoi(Value);
00600   else if (!strcasecmp(Name, "SubtitleLanguages"))   return ParseLanguages(Value, SubtitleLanguages);
00601   else if (!strcasecmp(Name, "SubtitleOffset"))      SubtitleOffset     = atoi(Value);
00602   else if (!strcasecmp(Name, "SubtitleFgTransparency")) SubtitleFgTransparency = atoi(Value);
00603   else if (!strcasecmp(Name, "SubtitleBgTransparency")) SubtitleBgTransparency = atoi(Value);
00604   else if (!strcasecmp(Name, "EPGLanguages"))        return ParseLanguages(Value, EPGLanguages);
00605   else if (!strcasecmp(Name, "EPGScanTimeout"))      EPGScanTimeout     = atoi(Value);
00606   else if (!strcasecmp(Name, "EPGBugfixLevel"))      EPGBugfixLevel     = atoi(Value);
00607   else if (!strcasecmp(Name, "EPGLinger"))           EPGLinger          = atoi(Value);
00608   else if (!strcasecmp(Name, "SVDRPTimeout"))        SVDRPTimeout       = atoi(Value);
00609   else if (!strcasecmp(Name, "ZapTimeout"))          ZapTimeout         = atoi(Value);
00610   else if (!strcasecmp(Name, "ChannelEntryTimeout")) ChannelEntryTimeout= atoi(Value);
00611   else if (!strcasecmp(Name, "DefaultPriority"))     DefaultPriority    = atoi(Value);
00612   else if (!strcasecmp(Name, "DefaultLifetime"))     DefaultLifetime    = atoi(Value);
00613   else if (!strcasecmp(Name, "PauseKeyHandling"))    PauseKeyHandling   = atoi(Value);
00614   else if (!strcasecmp(Name, "PausePriority"))       PausePriority      = atoi(Value);
00615   else if (!strcasecmp(Name, "PauseLifetime"))       PauseLifetime      = atoi(Value);
00616   else if (!strcasecmp(Name, "UseSubtitle"))         UseSubtitle        = atoi(Value);
00617   else if (!strcasecmp(Name, "UseVps"))              UseVps             = atoi(Value);
00618   else if (!strcasecmp(Name, "VpsMargin"))           VpsMargin          = atoi(Value);
00619   else if (!strcasecmp(Name, "RecordingDirs"))       RecordingDirs      = atoi(Value);
00620   else if (!strcasecmp(Name, "FoldersInTimerMenu"))  FoldersInTimerMenu = atoi(Value);
00621   else if (!strcasecmp(Name, "NumberKeysForChars"))  NumberKeysForChars = atoi(Value);
00622   else if (!strcasecmp(Name, "VideoDisplayFormat"))  VideoDisplayFormat = atoi(Value);
00623   else if (!strcasecmp(Name, "VideoFormat"))         VideoFormat        = atoi(Value);
00624   else if (!strcasecmp(Name, "UpdateChannels"))      UpdateChannels     = atoi(Value);
00625   else if (!strcasecmp(Name, "UseDolbyDigital"))     UseDolbyDigital    = atoi(Value);
00626   else if (!strcasecmp(Name, "ChannelInfoPos"))      ChannelInfoPos     = atoi(Value);
00627   else if (!strcasecmp(Name, "ChannelInfoTime"))     ChannelInfoTime    = atoi(Value);
00628   else if (!strcasecmp(Name, "OSDLeftP"))            OSDLeftP           = atof(Value);
00629   else if (!strcasecmp(Name, "OSDTopP"))             OSDTopP            = atof(Value);
00630   else if (!strcasecmp(Name, "OSDWidthP"))         { OSDWidthP          = atof(Value); ChkDoublePlausibility(OSDWidthP, 0.87); }
00631   else if (!strcasecmp(Name, "OSDHeightP"))        { OSDHeightP         = atof(Value); ChkDoublePlausibility(OSDHeightP, 0.84); }
00632   else if (!strcasecmp(Name, "OSDLeft"))             OSDLeft            = atoi(Value);
00633   else if (!strcasecmp(Name, "OSDTop"))              OSDTop             = atoi(Value);
00634   else if (!strcasecmp(Name, "OSDWidth"))          { OSDWidth           = atoi(Value); OSDWidth &= ~0x07; } // OSD width must be a multiple of 8
00635   else if (!strcasecmp(Name, "OSDHeight"))           OSDHeight          = atoi(Value);
00636   else if (!strcasecmp(Name, "OSDAspect"))           OSDAspect          = atof(Value);
00637   else if (!strcasecmp(Name, "OSDMessageTime"))      OSDMessageTime     = atoi(Value);
00638   else if (!strcasecmp(Name, "UseSmallFont"))        UseSmallFont       = atoi(Value);
00639   else if (!strcasecmp(Name, "AntiAlias"))           AntiAlias          = atoi(Value);
00640   else if (!strcasecmp(Name, "FontOsd"))             Utf8Strn0Cpy(FontOsd, Value, MAXFONTNAME);
00641   else if (!strcasecmp(Name, "FontSml"))             Utf8Strn0Cpy(FontSml, Value, MAXFONTNAME);
00642   else if (!strcasecmp(Name, "FontFix"))             Utf8Strn0Cpy(FontFix, Value, MAXFONTNAME);
00643   else if (!strcasecmp(Name, "FontOsdSizeP"))      { FontOsdSizeP       = atof(Value); ChkDoublePlausibility(FontOsdSizeP, 0.038); }
00644   else if (!strcasecmp(Name, "FontSmlSizeP"))      { FontSmlSizeP       = atof(Value); ChkDoublePlausibility(FontSmlSizeP, 0.035); }
00645   else if (!strcasecmp(Name, "FontFixSizeP"))      { FontFixSizeP       = atof(Value); ChkDoublePlausibility(FontFixSizeP, 0.031); }
00646   else if (!strcasecmp(Name, "FontOsdSize"))         FontOsdSize        = atoi(Value);
00647   else if (!strcasecmp(Name, "FontSmlSize"))         FontSmlSize        = atoi(Value);
00648   else if (!strcasecmp(Name, "FontFixSize"))         FontFixSize        = atoi(Value);
00649   else if (!strcasecmp(Name, "MaxVideoFileSize"))    MaxVideoFileSize   = atoi(Value);
00650   else if (!strcasecmp(Name, "MaxRecordingSize"))    MaxRecordingSize   = atoi(Value);
00651   else if (!strcasecmp(Name, "SplitEditedFiles"))    SplitEditedFiles   = atoi(Value);
00652   else if (!strcasecmp(Name, "DelTimeshiftRec"))     DelTimeshiftRec    = atoi(Value);
00653   else if (!strcasecmp(Name, "HardLinkCutter"))      HardLinkCutter     = atoi(Value);
00654   else if (!strcasecmp(Name, "MinEventTimeout"))     MinEventTimeout    = atoi(Value);
00655   else if (!strcasecmp(Name, "MinUserInactivity"))   MinUserInactivity  = atoi(Value);
00656   else if (!strcasecmp(Name, "NextWakeupTime"))      NextWakeupTime     = atoi(Value);
00657   else if (!strcasecmp(Name, "MultiSpeedMode"))      MultiSpeedMode     = atoi(Value);
00658   else if (!strcasecmp(Name, "ShowReplayMode"))      ShowReplayMode     = atoi(Value);
00659   else if (!strcasecmp(Name, "ShowRemainingTime"))   ShowRemainingTime  = atoi(Value);
00660   else if (!strcasecmp(Name, "ResumeID"))            ResumeID           = atoi(Value);
00661   else if (!strcasecmp(Name, "JumpPlay"))            JumpPlay           = atoi(Value);
00662   else if (!strcasecmp(Name, "PlayJump"))            PlayJump           = atoi(Value);
00663   else if (!strcasecmp(Name, "PauseLastMark"))       PauseLastMark      = atoi(Value);
00664   else if (!strcasecmp(Name, "CurrentChannel"))      CurrentChannel     = atoi(Value);
00665   else if (!strcasecmp(Name, "CurrentVolume"))       CurrentVolume      = atoi(Value);
00666   else if (!strcasecmp(Name, "CurrentDolby"))        CurrentDolby       = atoi(Value);
00667   else if (!strcasecmp(Name, "InitialChannel"))      InitialChannel     = Value;
00668   else if (!strcasecmp(Name, "InitialVolume"))       InitialVolume      = atoi(Value);
00669   else if (!strcasecmp(Name, "DeviceBondings"))      DeviceBondings     = Value;
00670   else if (!strcasecmp(Name, "ChannelsWrap"))        ChannelsWrap       = atoi(Value);
00671   else if (!strcasecmp(Name, "EmergencyExit"))       EmergencyExit      = atoi(Value);
00672   else
00673      return false;
00674   return true;
00675 }
00676 
00677 bool cSetup::Save(void)
00678 {
00679   Store("OSDLanguage",        OSDLanguage);
00680   Store("OSDSkin",            OSDSkin);
00681   Store("OSDTheme",           OSDTheme);
00682   Store("PrimaryDVB",         PrimaryDVB);
00683   Store("ShowInfoOnChSwitch", ShowInfoOnChSwitch);
00684   Store("TimeoutRequChInfo",  TimeoutRequChInfo);
00685   Store("MenuScrollPage",     MenuScrollPage);
00686   Store("MenuScrollWrap",     MenuScrollWrap);
00687   Store("MenuKeyCloses",      MenuKeyCloses);
00688   Store("MarkInstantRecord",  MarkInstantRecord);
00689   Store("NameInstantRecord",  NameInstantRecord);
00690   Store("InstantRecordTime",  InstantRecordTime);
00691   Store("LnbSLOF",            LnbSLOF);
00692   Store("LnbFrequLo",         LnbFrequLo);
00693   Store("LnbFrequHi",         LnbFrequHi);
00694   Store("DiSEqC",             DiSEqC);
00695   Store("SetSystemTime",      SetSystemTime);
00696   Store("TimeSource",         cSource::ToString(TimeSource));
00697   Store("TimeTransponder",    TimeTransponder);
00698   Store("MarginStart",        MarginStart);
00699   Store("MarginStop",         MarginStop);
00700   StoreLanguages("AudioLanguages", AudioLanguages);
00701   Store("DisplaySubtitles",   DisplaySubtitles);
00702   Store("SupportTeletext",    SupportTeletext);
00703   StoreLanguages("SubtitleLanguages", SubtitleLanguages);
00704   Store("SubtitleOffset",     SubtitleOffset);
00705   Store("SubtitleFgTransparency", SubtitleFgTransparency);
00706   Store("SubtitleBgTransparency", SubtitleBgTransparency);
00707   StoreLanguages("EPGLanguages", EPGLanguages);
00708   Store("EPGScanTimeout",     EPGScanTimeout);
00709   Store("EPGBugfixLevel",     EPGBugfixLevel);
00710   Store("EPGLinger",          EPGLinger);
00711   Store("SVDRPTimeout",       SVDRPTimeout);
00712   Store("ZapTimeout",         ZapTimeout);
00713   Store("ChannelEntryTimeout",ChannelEntryTimeout);
00714   Store("DefaultPriority",    DefaultPriority);
00715   Store("DefaultLifetime",    DefaultLifetime);
00716   Store("PauseKeyHandling",   PauseKeyHandling);
00717   Store("PausePriority",      PausePriority);
00718   Store("PauseLifetime",      PauseLifetime);
00719   Store("UseSubtitle",        UseSubtitle);
00720   Store("UseVps",             UseVps);
00721   Store("VpsMargin",          VpsMargin);
00722   Store("RecordingDirs",      RecordingDirs);
00723   Store("FoldersInTimerMenu", FoldersInTimerMenu);
00724   Store("NumberKeysForChars", NumberKeysForChars);
00725   Store("VideoDisplayFormat", VideoDisplayFormat);
00726   Store("VideoFormat",        VideoFormat);
00727   Store("UpdateChannels",     UpdateChannels);
00728   Store("UseDolbyDigital",    UseDolbyDigital);
00729   Store("ChannelInfoPos",     ChannelInfoPos);
00730   Store("ChannelInfoTime",    ChannelInfoTime);
00731   Store("OSDLeftP",           OSDLeftP);
00732   Store("OSDTopP",            OSDTopP);
00733   Store("OSDWidthP",          OSDWidthP);
00734   Store("OSDHeightP",         OSDHeightP);
00735   Store("OSDLeft",            OSDLeft);
00736   Store("OSDTop",             OSDTop);
00737   Store("OSDWidth",           OSDWidth);
00738   Store("OSDHeight",          OSDHeight);
00739   Store("OSDAspect",          OSDAspect);
00740   Store("OSDMessageTime",     OSDMessageTime);
00741   Store("UseSmallFont",       UseSmallFont);
00742   Store("AntiAlias",          AntiAlias);
00743   Store("FontOsd",            FontOsd);
00744   Store("FontSml",            FontSml);
00745   Store("FontFix",            FontFix);
00746   Store("FontOsdSizeP",       FontOsdSizeP);
00747   Store("FontSmlSizeP",       FontSmlSizeP);
00748   Store("FontFixSizeP",       FontFixSizeP);
00749   Store("FontOsdSize",        FontOsdSize);
00750   Store("FontSmlSize",        FontSmlSize);
00751   Store("FontFixSize",        FontFixSize);
00752   Store("MaxVideoFileSize",   MaxVideoFileSize);
00753   Store("MaxRecordingSize",   MaxRecordingSize);
00754   Store("SplitEditedFiles",   SplitEditedFiles);
00755   Store("DelTimeshiftRec",    DelTimeshiftRec);
00756   Store("HardLinkCutter",     HardLinkCutter);
00757   Store("MinEventTimeout",    MinEventTimeout);
00758   Store("MinUserInactivity",  MinUserInactivity);
00759   Store("NextWakeupTime",     NextWakeupTime);
00760   Store("MultiSpeedMode",     MultiSpeedMode);
00761   Store("ShowReplayMode",     ShowReplayMode);
00762   Store("ShowRemainingTime",  ShowRemainingTime);
00763   Store("ResumeID",           ResumeID);
00764   Store("JumpPlay",           JumpPlay);
00765   Store("PlayJump",           PlayJump);
00766   Store("PauseLastMark",      PauseLastMark);
00767   Store("CurrentChannel",     CurrentChannel);
00768   Store("CurrentVolume",      CurrentVolume);
00769   Store("CurrentDolby",       CurrentDolby);
00770   Store("InitialChannel",     InitialChannel);
00771   Store("InitialVolume",      InitialVolume);
00772   Store("DeviceBondings",     DeviceBondings);
00773   Store("ChannelsWrap",       ChannelsWrap);
00774   Store("EmergencyExit",      EmergencyExit);
00775 
00776   Sort();
00777 
00778   if (cConfig<cSetupLine>::Save()) {
00779      isyslog("saved setup to %s", FileName());
00780      return true;
00781      }
00782   return false;
00783 }