vdr  2.2.0
config.c
Go to the documentation of this file.
1 /*
2  * config.c: Configuration file handling
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: config.c 3.10 2015/02/10 12:24:13 kls Exp $
8  */
9 
10 #include "config.h"
11 #include <ctype.h>
12 #include <stdlib.h>
13 #include "device.h"
14 #include "i18n.h"
15 #include "interface.h"
16 #include "menu.h"
17 #include "plugin.h"
18 #include "recording.h"
19 
20 // IMPORTANT NOTE: in the 'sscanf()' calls there is a blank after the '%d'
21 // format characters in order to allow any number of blanks after a numeric
22 // value!
23 
24 #define ChkDoublePlausibility(Variable, Default) { if (Variable < 0.00001) Variable = Default; }
25 
26 // --- cSVDRPhost ------------------------------------------------------------
27 
29 {
30  addr.s_addr = 0;
31  mask = 0;
32 }
33 
34 bool cSVDRPhost::Parse(const char *s)
35 {
36  mask = 0xFFFFFFFF;
37  const char *p = strchr(s, '/');
38  if (p) {
39  char *error = NULL;
40  int m = strtoul(p + 1, &error, 10);
41  if (error && *error && !isspace(*error) || m > 32)
42  return false;
43  *(char *)p = 0; // yes, we know it's 'const' - will be restored!
44  if (m == 0)
45  mask = 0;
46  else {
47  mask <<= (32 - m);
48  mask = htonl(mask);
49  }
50  }
51  int result = inet_aton(s, &addr);
52  if (p)
53  *(char *)p = '/'; // there it is again
54  return result != 0 && (mask != 0 || addr.s_addr == 0);
55 }
56 
58 {
59  return addr.s_addr == htonl(INADDR_LOOPBACK);
60 }
61 
63 {
64  return (Address & mask) == (addr.s_addr & mask);
65 }
66 
67 // --- cSatCableNumbers ------------------------------------------------------
68 
69 cSatCableNumbers::cSatCableNumbers(int Size, const char *s)
70 {
71  size = Size;
72  array = MALLOC(int, size);
73  FromString(s);
74 }
75 
77 {
78  free(array);
79 }
80 
81 bool cSatCableNumbers::FromString(const char *s)
82 {
83  char *t;
84  int i = 0;
85  const char *p = s;
86  while (p && *p) {
87  int n = strtol(p, &t, 10);
88  if (t != p) {
89  if (i < size)
90  array[i++] = n;
91  else {
92  esyslog("ERROR: too many sat cable numbers in '%s'", s);
93  return false;
94  }
95  }
96  else {
97  esyslog("ERROR: invalid sat cable number in '%s'", s);
98  return false;
99  }
100  p = skipspace(t);
101  }
102  for ( ; i < size; i++)
103  array[i] = 0;
104  return true;
105 }
106 
108 {
109  cString s("");
110  for (int i = 0; i < size; i++) {
111  s = cString::sprintf("%s%d ", *s, array[i]);
112  }
113  return s;
114 }
115 
116 int cSatCableNumbers::FirstDeviceIndex(int DeviceIndex) const
117 {
118  if (0 <= DeviceIndex && DeviceIndex < size) {
119  if (int CableNr = array[DeviceIndex]) {
120  for (int i = 0; i < size; i++) {
121  if (i < DeviceIndex && array[i] == CableNr)
122  return i;
123  }
124  }
125  }
126  return -1;
127 }
128 
129 // --- cNestedItem -----------------------------------------------------------
130 
131 cNestedItem::cNestedItem(const char *Text, bool WithSubItems)
132 {
133  text = strdup(Text ? Text : "");
134  subItems = WithSubItems ? new cList<cNestedItem> : NULL;
135 }
136 
138 {
139  delete subItems;
140  free(text);
141 }
142 
143 int cNestedItem::Compare(const cListObject &ListObject) const
144 {
145  return strcasecmp(text, ((cNestedItem *)&ListObject)->text);
146 }
147 
149 {
150  if (!subItems)
151  subItems = new cList<cNestedItem>;
152  if (Item)
153  subItems->Add(Item);
154 }
155 
156 void cNestedItem::SetText(const char *Text)
157 {
158  free(text);
159  text = strdup(Text ? Text : "");
160 }
161 
163 {
164  if (On && !subItems)
165  subItems = new cList<cNestedItem>;
166  else if (!On && subItems) {
167  delete subItems;
168  subItems = NULL;
169  }
170 }
171 
172 // --- cNestedItemList -------------------------------------------------------
173 
175 {
176  fileName = NULL;
177 }
178 
180 {
181  free(fileName);
182 }
183 
184 bool cNestedItemList::Parse(FILE *f, cList<cNestedItem> *List, int &Line)
185 {
186  char *s;
187  cReadLine ReadLine;
188  while ((s = ReadLine.Read(f)) != NULL) {
189  Line++;
190  char *p = strchr(s, '#');
191  if (p)
192  *p = 0;
193  s = skipspace(stripspace(s));
194  if (!isempty(s)) {
195  p = s + strlen(s) - 1;
196  if (*p == '{') {
197  *p = 0;
198  stripspace(s);
199  cNestedItem *Item = new cNestedItem(s, true);
200  List->Add(Item);
201  if (!Parse(f, Item->SubItems(), Line))
202  return false;
203  }
204  else if (*s == '}')
205  break;
206  else
207  List->Add(new cNestedItem(s));
208  }
209  }
210  return true;
211 }
212 
213 bool cNestedItemList::Write(FILE *f, cList<cNestedItem> *List, int Indent)
214 {
215  for (cNestedItem *Item = List->First(); Item; Item = List->Next(Item)) {
216  if (Item->SubItems()) {
217  fprintf(f, "%*s%s {\n", Indent, "", Item->Text());
218  Write(f, Item->SubItems(), Indent + 2);
219  fprintf(f, "%*s}\n", Indent + 2, "");
220  }
221  else
222  fprintf(f, "%*s%s\n", Indent, "", Item->Text());
223  }
224  return true;
225 }
226 
228 {
229  free(fileName);
230  fileName = NULL;
232 }
233 
234 bool cNestedItemList::Load(const char *FileName)
235 {
237  if (FileName) {
238  free(fileName);
239  fileName = strdup(FileName);
240  }
241  bool result = false;
242  if (fileName && access(fileName, F_OK) == 0) {
243  isyslog("loading %s", fileName);
244  FILE *f = fopen(fileName, "r");
245  if (f) {
246  int Line = 0;
247  result = Parse(f, this, Line);
248  fclose(f);
249  }
250  else {
251  LOG_ERROR_STR(fileName);
252  result = false;
253  }
254  }
255  return result;
256 }
257 
259 {
260  bool result = true;
261  cSafeFile f(fileName);
262  if (f.Open()) {
263  result = Write(f, this);
264  if (!f.Close())
265  result = false;
266  }
267  else
268  result = false;
269  return result;
270 }
271 
272 // --- Folders and Commands --------------------------------------------------
273 
277 
278 // --- cSVDRPhosts -----------------------------------------------------------
279 
281 
283 {
284  cSVDRPhost *h = First();
285  while (h) {
286  if (!h->IsLocalhost())
287  return false;
288  h = (cSVDRPhost *)h->Next();
289  }
290  return true;
291 }
292 
294 {
295  cSVDRPhost *h = First();
296  while (h) {
297  if (h->Accepts(Address))
298  return true;
299  h = (cSVDRPhost *)h->Next();
300  }
301  return false;
302 }
303 
304 // --- cSetupLine ------------------------------------------------------------
305 
307 {
308  plugin = name = value = NULL;
309 }
310 
311 cSetupLine::cSetupLine(const char *Name, const char *Value, const char *Plugin)
312 {
313  name = strreplace(strdup(Name), '\n', 0);
314  value = strreplace(strdup(Value), '\n', 0);
315  plugin = Plugin ? strreplace(strdup(Plugin), '\n', 0) : NULL;
316 }
317 
319 {
320  free(plugin);
321  free(name);
322  free(value);
323 }
324 
325 int cSetupLine::Compare(const cListObject &ListObject) const
326 {
327  const cSetupLine *sl = (cSetupLine *)&ListObject;
328  if (!plugin && !sl->plugin)
329  return strcasecmp(name, sl->name);
330  if (!plugin)
331  return -1;
332  if (!sl->plugin)
333  return 1;
334  int result = strcasecmp(plugin, sl->plugin);
335  if (result == 0)
336  result = strcasecmp(name, sl->name);
337  return result;
338 }
339 
340 bool cSetupLine::Parse(char *s)
341 {
342  char *p = strchr(s, '=');
343  if (p) {
344  *p = 0;
345  char *Name = compactspace(s);
346  char *Value = compactspace(p + 1);
347  if (*Name) { // value may be an empty string
348  p = strchr(Name, '.');
349  if (p) {
350  *p = 0;
351  char *Plugin = compactspace(Name);
352  Name = compactspace(p + 1);
353  if (!(*Plugin && *Name))
354  return false;
355  plugin = strdup(Plugin);
356  }
357  name = strdup(Name);
358  value = strdup(Value);
359  return true;
360  }
361  }
362  return false;
363 }
364 
365 bool cSetupLine::Save(FILE *f)
366 {
367  return fprintf(f, "%s%s%s = %s\n", plugin ? plugin : "", plugin ? "." : "", name, value) > 0;
368 }
369 
370 // --- cSetup ----------------------------------------------------------------
371 
373 
375 {
376  strcpy(OSDLanguage, ""); // default is taken from environment
377  strcpy(OSDSkin, "lcars");
378  strcpy(OSDTheme, "default");
379  WarEagleIcons = 1;
380  PrimaryDVB = 1;
381  ShowInfoOnChSwitch = 1;
382  TimeoutRequChInfo = 1;
383  MenuScrollPage = 1;
384  MenuScrollWrap = 0;
385  MenuKeyCloses = 0;
386  MarkInstantRecord = 1;
387  strcpy(NameInstantRecord, TIMERMACRO_TITLE " " TIMERMACRO_EPISODE);
388  InstantRecordTime = DEFINSTRECTIME;
389  LnbSLOF = 11700;
390  LnbFrequLo = 9750;
391  LnbFrequHi = 10600;
392  DiSEqC = 0;
393  UsePositioner = 0;
394  SiteLat = 0;
395  SiteLon = 0;
396  PositionerSpeed = 15;
397  PositionerSwing = 650;
398  PositionerLastLon = 0;
399  SetSystemTime = 0;
400  TimeSource = 0;
401  TimeTransponder = 0;
402  StandardCompliance = STANDARD_DVB;
403  MarginStart = 2;
404  MarginStop = 10;
405  AudioLanguages[0] = -1;
406  DisplaySubtitles = 0;
407  SubtitleLanguages[0] = -1;
408  SubtitleOffset = 0;
409  SubtitleFgTransparency = 0;
410  SubtitleBgTransparency = 0;
411  EPGLanguages[0] = -1;
412  EPGScanTimeout = 5;
413  EPGBugfixLevel = 3;
414  EPGLinger = 0;
415  SVDRPTimeout = 300;
416  ZapTimeout = 3;
417  ChannelEntryTimeout = 1000;
418  RcRepeatDelay = 300;
419  RcRepeatDelta = 100;
420  DefaultPriority = 50;
421  DefaultLifetime = MAXLIFETIME;
422  PauseKeyHandling = 2;
423  PausePriority = 10;
424  PauseLifetime = 1;
425  UseSubtitle = 1;
426  UseVps = 0;
427  VpsMargin = 120;
428  RecordingDirs = 1;
429  FoldersInTimerMenu = 1;
430  AlwaysSortFoldersFirst = 1;
431  NumberKeysForChars = 1;
432  ColorKey0 = 0;
433  ColorKey1 = 1;
434  ColorKey2 = 2;
435  ColorKey3 = 3;
436  VideoDisplayFormat = 1;
437  VideoFormat = 0;
438  UpdateChannels = 5;
439  UseDolbyDigital = 1;
440  ChannelInfoPos = 0;
441  ChannelInfoTime = 5;
442  OSDLeftP = 0.08;
443  OSDTopP = 0.08;
444  OSDWidthP = 0.87;
445  OSDHeightP = 0.84;
446  OSDLeft = 54;
447  OSDTop = 45;
448  OSDWidth = 624;
449  OSDHeight = 486;
450  OSDAspect = 1.0;
451  OSDMessageTime = 1;
452  UseSmallFont = 1;
453  AntiAlias = 1;
454  strcpy(FontOsd, DefaultFontOsd);
455  strcpy(FontSml, DefaultFontSml);
456  strcpy(FontFix, DefaultFontFix);
457  FontOsdSizeP = 0.031;
458  FontSmlSizeP = 0.028;
459  FontFixSizeP = 0.030;
460  FontOsdSize = 22;
461  FontSmlSize = 18;
462  FontFixSize = 20;
463  MaxVideoFileSize = MAXVIDEOFILESIZEDEFAULT;
464  SplitEditedFiles = 0;
465  DelTimeshiftRec = 0;
466  MinEventTimeout = 30;
467  MinUserInactivity = 300;
468  NextWakeupTime = 0;
469  MultiSpeedMode = 0;
470  ShowReplayMode = 0;
471  ShowRemainingTime = 0;
472  ProgressDisplayTime = 0;
473  PauseOnMarkSet = 0;
474  PauseOnMarkJump = 1;
475  SkipEdited = 0;
476  PauseAtLastMark = 0;
477  AdaptiveSkipInitial = 120;
478  AdaptiveSkipTimeout = 3;
479  AdaptiveSkipAlternate = 0;
480  AdaptiveSkipPrevNext = 0;
481  SkipSeconds = 60;
482  SkipSecondsRepeat = 60;
483  ResumeID = 0;
484  CurrentChannel = -1;
485  CurrentVolume = MAXVOLUME;
486  VolumeSteps = 51;
487  VolumeLinearize = 0;
488  CurrentDolby = 0;
489  InitialChannel = "";
490  DeviceBondings = "";
491  InitialVolume = -1;
492  ChannelsWrap = 0;
493  ShowChannelNamesWithSource = 0;
494  EmergencyExit = 1;
495 }
496 
498 {
499  memcpy(&__BeginData__, &s.__BeginData__, (char *)&s.__EndData__ - (char *)&s.__BeginData__);
500  InitialChannel = s.InitialChannel;
501  DeviceBondings = s.DeviceBondings;
502  return *this;
503 }
504 
505 cSetupLine *cSetup::Get(const char *Name, const char *Plugin)
506 {
507  for (cSetupLine *l = First(); l; l = Next(l)) {
508  if ((l->Plugin() == NULL) == (Plugin == NULL)) {
509  if ((!Plugin || strcasecmp(l->Plugin(), Plugin) == 0) && strcasecmp(l->Name(), Name) == 0)
510  return l;
511  }
512  }
513  return NULL;
514 }
515 
516 void cSetup::Store(const char *Name, const char *Value, const char *Plugin, bool AllowMultiple)
517 {
518  if (Name && *Name) {
519  cSetupLine *l = Get(Name, Plugin);
520  if (l && !AllowMultiple)
521  Del(l);
522  if (Value)
523  Add(new cSetupLine(Name, Value, Plugin));
524  }
525 }
526 
527 void cSetup::Store(const char *Name, int Value, const char *Plugin)
528 {
529  Store(Name, cString::sprintf("%d", Value), Plugin);
530 }
531 
532 void cSetup::Store(const char *Name, double &Value, const char *Plugin)
533 {
534  Store(Name, dtoa(Value), Plugin);
535 }
536 
537 bool cSetup::Load(const char *FileName)
538 {
539  if (cConfig<cSetupLine>::Load(FileName)) {
540  bool result = true;
541  for (cSetupLine *l = First(); l; l = Next(l)) {
542  bool error = false;
543  if (l->Plugin()) {
544  cPlugin *p = cPluginManager::GetPlugin(l->Plugin());
545  if (p && !p->SetupParse(l->Name(), l->Value()))
546  error = true;
547  }
548  else {
549  if (!Parse(l->Name(), l->Value()))
550  error = true;
551  }
552  if (error) {
553  esyslog("ERROR: unknown config parameter: %s%s%s = %s", l->Plugin() ? l->Plugin() : "", l->Plugin() ? "." : "", l->Name(), l->Value());
554  result = false;
555  }
556  }
557  return result;
558  }
559  return false;
560 }
561 
562 void cSetup::StoreLanguages(const char *Name, int *Values)
563 {
564  char buffer[I18nLanguages()->Size() * 4];
565  char *q = buffer;
566  for (int i = 0; i < I18nLanguages()->Size(); i++) {
567  if (Values[i] < 0)
568  break;
569  const char *s = I18nLanguageCode(Values[i]);
570  if (s) {
571  if (q > buffer)
572  *q++ = ' ';
573  strncpy(q, s, 3);
574  q += 3;
575  }
576  }
577  *q = 0;
578  Store(Name, buffer);
579 }
580 
581 bool cSetup::ParseLanguages(const char *Value, int *Values)
582 {
583  int n = 0;
584  while (Value && *Value && n < I18nLanguages()->Size()) {
585  char buffer[4];
586  strn0cpy(buffer, Value, sizeof(buffer));
587  int i = I18nLanguageIndex(buffer);
588  if (i >= 0)
589  Values[n++] = i;
590  if ((Value = strchr(Value, ' ')) != NULL)
591  Value++;
592  }
593  Values[n] = -1;
594  return true;
595 }
596 
597 bool cSetup::Parse(const char *Name, const char *Value)
598 {
599  if (!strcasecmp(Name, "OSDLanguage")) { strn0cpy(OSDLanguage, Value, sizeof(OSDLanguage)); I18nSetLocale(OSDLanguage); }
600  else if (!strcasecmp(Name, "OSDSkin")) Utf8Strn0Cpy(OSDSkin, Value, MaxSkinName);
601  else if (!strcasecmp(Name, "OSDTheme")) Utf8Strn0Cpy(OSDTheme, Value, MaxThemeName);
602  else if (!strcasecmp(Name, "WarEagleIcons")) WarEagleIcons = atoi(Value);
603  else if (!strcasecmp(Name, "PrimaryDVB")) PrimaryDVB = atoi(Value);
604  else if (!strcasecmp(Name, "ShowInfoOnChSwitch")) ShowInfoOnChSwitch = atoi(Value);
605  else if (!strcasecmp(Name, "TimeoutRequChInfo")) TimeoutRequChInfo = atoi(Value);
606  else if (!strcasecmp(Name, "MenuScrollPage")) MenuScrollPage = atoi(Value);
607  else if (!strcasecmp(Name, "MenuScrollWrap")) MenuScrollWrap = atoi(Value);
608  else if (!strcasecmp(Name, "MenuKeyCloses")) MenuKeyCloses = atoi(Value);
609  else if (!strcasecmp(Name, "MarkInstantRecord")) MarkInstantRecord = atoi(Value);
610  else if (!strcasecmp(Name, "NameInstantRecord")) Utf8Strn0Cpy(NameInstantRecord, Value, sizeof(NameInstantRecord));
611  else if (!strcasecmp(Name, "InstantRecordTime")) InstantRecordTime = atoi(Value);
612  else if (!strcasecmp(Name, "LnbSLOF")) LnbSLOF = atoi(Value);
613  else if (!strcasecmp(Name, "LnbFrequLo")) LnbFrequLo = atoi(Value);
614  else if (!strcasecmp(Name, "LnbFrequHi")) LnbFrequHi = atoi(Value);
615  else if (!strcasecmp(Name, "DiSEqC")) DiSEqC = atoi(Value);
616  else if (!strcasecmp(Name, "UsePositioner")) UsePositioner = atoi(Value);
617  else if (!strcasecmp(Name, "SiteLat")) SiteLat = atoi(Value);
618  else if (!strcasecmp(Name, "SiteLon")) SiteLon = atoi(Value);
619  else if (!strcasecmp(Name, "PositionerSpeed")) PositionerSpeed = atoi(Value);
620  else if (!strcasecmp(Name, "PositionerSwing")) PositionerSwing = atoi(Value);
621  else if (!strcasecmp(Name, "PositionerLastLon")) PositionerLastLon = atoi(Value);
622  else if (!strcasecmp(Name, "SetSystemTime")) SetSystemTime = atoi(Value);
623  else if (!strcasecmp(Name, "TimeSource")) TimeSource = cSource::FromString(Value);
624  else if (!strcasecmp(Name, "TimeTransponder")) TimeTransponder = atoi(Value);
625  else if (!strcasecmp(Name, "StandardCompliance")) StandardCompliance = atoi(Value);
626  else if (!strcasecmp(Name, "MarginStart")) MarginStart = atoi(Value);
627  else if (!strcasecmp(Name, "MarginStop")) MarginStop = atoi(Value);
628  else if (!strcasecmp(Name, "AudioLanguages")) return ParseLanguages(Value, AudioLanguages);
629  else if (!strcasecmp(Name, "DisplaySubtitles")) DisplaySubtitles = atoi(Value);
630  else if (!strcasecmp(Name, "SubtitleLanguages")) return ParseLanguages(Value, SubtitleLanguages);
631  else if (!strcasecmp(Name, "SubtitleOffset")) SubtitleOffset = atoi(Value);
632  else if (!strcasecmp(Name, "SubtitleFgTransparency")) SubtitleFgTransparency = atoi(Value);
633  else if (!strcasecmp(Name, "SubtitleBgTransparency")) SubtitleBgTransparency = atoi(Value);
634  else if (!strcasecmp(Name, "EPGLanguages")) return ParseLanguages(Value, EPGLanguages);
635  else if (!strcasecmp(Name, "EPGScanTimeout")) EPGScanTimeout = atoi(Value);
636  else if (!strcasecmp(Name, "EPGBugfixLevel")) EPGBugfixLevel = atoi(Value);
637  else if (!strcasecmp(Name, "EPGLinger")) EPGLinger = atoi(Value);
638  else if (!strcasecmp(Name, "SVDRPTimeout")) SVDRPTimeout = atoi(Value);
639  else if (!strcasecmp(Name, "ZapTimeout")) ZapTimeout = atoi(Value);
640  else if (!strcasecmp(Name, "ChannelEntryTimeout")) ChannelEntryTimeout= atoi(Value);
641  else if (!strcasecmp(Name, "RcRepeatDelay")) RcRepeatDelay = atoi(Value);
642  else if (!strcasecmp(Name, "RcRepeatDelta")) RcRepeatDelta = atoi(Value);
643  else if (!strcasecmp(Name, "DefaultPriority")) DefaultPriority = atoi(Value);
644  else if (!strcasecmp(Name, "DefaultLifetime")) DefaultLifetime = atoi(Value);
645  else if (!strcasecmp(Name, "PauseKeyHandling")) PauseKeyHandling = atoi(Value);
646  else if (!strcasecmp(Name, "PausePriority")) PausePriority = atoi(Value);
647  else if (!strcasecmp(Name, "PauseLifetime")) PauseLifetime = atoi(Value);
648  else if (!strcasecmp(Name, "UseSubtitle")) UseSubtitle = atoi(Value);
649  else if (!strcasecmp(Name, "UseVps")) UseVps = atoi(Value);
650  else if (!strcasecmp(Name, "VpsMargin")) VpsMargin = atoi(Value);
651  else if (!strcasecmp(Name, "RecordingDirs")) RecordingDirs = atoi(Value);
652  else if (!strcasecmp(Name, "FoldersInTimerMenu")) FoldersInTimerMenu = atoi(Value);
653  else if (!strcasecmp(Name, "AlwaysSortFoldersFirst")) AlwaysSortFoldersFirst = atoi(Value);
654  else if (!strcasecmp(Name, "NumberKeysForChars")) NumberKeysForChars = atoi(Value);
655  else if (!strcasecmp(Name, "ColorKey0")) ColorKey0 = atoi(Value);
656  else if (!strcasecmp(Name, "ColorKey1")) ColorKey1 = atoi(Value);
657  else if (!strcasecmp(Name, "ColorKey2")) ColorKey2 = atoi(Value);
658  else if (!strcasecmp(Name, "ColorKey3")) ColorKey3 = atoi(Value);
659  else if (!strcasecmp(Name, "VideoDisplayFormat")) VideoDisplayFormat = atoi(Value);
660  else if (!strcasecmp(Name, "VideoFormat")) VideoFormat = atoi(Value);
661  else if (!strcasecmp(Name, "UpdateChannels")) UpdateChannels = atoi(Value);
662  else if (!strcasecmp(Name, "UseDolbyDigital")) UseDolbyDigital = atoi(Value);
663  else if (!strcasecmp(Name, "ChannelInfoPos")) ChannelInfoPos = atoi(Value);
664  else if (!strcasecmp(Name, "ChannelInfoTime")) ChannelInfoTime = atoi(Value);
665  else if (!strcasecmp(Name, "OSDLeftP")) OSDLeftP = atod(Value);
666  else if (!strcasecmp(Name, "OSDTopP")) OSDTopP = atod(Value);
667  else if (!strcasecmp(Name, "OSDWidthP")) { OSDWidthP = atod(Value); ChkDoublePlausibility(OSDWidthP, 0.87); }
668  else if (!strcasecmp(Name, "OSDHeightP")) { OSDHeightP = atod(Value); ChkDoublePlausibility(OSDHeightP, 0.84); }
669  else if (!strcasecmp(Name, "OSDLeft")) OSDLeft = atoi(Value);
670  else if (!strcasecmp(Name, "OSDTop")) OSDTop = atoi(Value);
671  else if (!strcasecmp(Name, "OSDWidth")) { OSDWidth = atoi(Value); OSDWidth &= ~0x07; } // OSD width must be a multiple of 8
672  else if (!strcasecmp(Name, "OSDHeight")) OSDHeight = atoi(Value);
673  else if (!strcasecmp(Name, "OSDAspect")) OSDAspect = atod(Value);
674  else if (!strcasecmp(Name, "OSDMessageTime")) OSDMessageTime = atoi(Value);
675  else if (!strcasecmp(Name, "UseSmallFont")) UseSmallFont = atoi(Value);
676  else if (!strcasecmp(Name, "AntiAlias")) AntiAlias = atoi(Value);
677  else if (!strcasecmp(Name, "FontOsd")) Utf8Strn0Cpy(FontOsd, Value, MAXFONTNAME);
678  else if (!strcasecmp(Name, "FontSml")) Utf8Strn0Cpy(FontSml, Value, MAXFONTNAME);
679  else if (!strcasecmp(Name, "FontFix")) Utf8Strn0Cpy(FontFix, Value, MAXFONTNAME);
680  else if (!strcasecmp(Name, "FontOsdSizeP")) { FontOsdSizeP = atod(Value); ChkDoublePlausibility(FontOsdSizeP, 0.038); }
681  else if (!strcasecmp(Name, "FontSmlSizeP")) { FontSmlSizeP = atod(Value); ChkDoublePlausibility(FontSmlSizeP, 0.035); }
682  else if (!strcasecmp(Name, "FontFixSizeP")) { FontFixSizeP = atod(Value); ChkDoublePlausibility(FontFixSizeP, 0.031); }
683  else if (!strcasecmp(Name, "FontOsdSize")) FontOsdSize = atoi(Value);
684  else if (!strcasecmp(Name, "FontSmlSize")) FontSmlSize = atoi(Value);
685  else if (!strcasecmp(Name, "FontFixSize")) FontFixSize = atoi(Value);
686  else if (!strcasecmp(Name, "MaxVideoFileSize")) MaxVideoFileSize = atoi(Value);
687  else if (!strcasecmp(Name, "SplitEditedFiles")) SplitEditedFiles = atoi(Value);
688  else if (!strcasecmp(Name, "DelTimeshiftRec")) DelTimeshiftRec = atoi(Value);
689  else if (!strcasecmp(Name, "MinEventTimeout")) MinEventTimeout = atoi(Value);
690  else if (!strcasecmp(Name, "MinUserInactivity")) MinUserInactivity = atoi(Value);
691  else if (!strcasecmp(Name, "NextWakeupTime")) NextWakeupTime = atoi(Value);
692  else if (!strcasecmp(Name, "MultiSpeedMode")) MultiSpeedMode = atoi(Value);
693  else if (!strcasecmp(Name, "ShowReplayMode")) ShowReplayMode = atoi(Value);
694  else if (!strcasecmp(Name, "ShowRemainingTime")) ShowRemainingTime = atoi(Value);
695  else if (!strcasecmp(Name, "ProgressDisplayTime")) ProgressDisplayTime= atoi(Value);
696  else if (!strcasecmp(Name, "PauseOnMarkSet")) PauseOnMarkSet = atoi(Value);
697  else if (!strcasecmp(Name, "PauseOnMarkJump")) PauseOnMarkJump = atoi(Value);
698  else if (!strcasecmp(Name, "SkipEdited")) SkipEdited = atoi(Value);
699  else if (!strcasecmp(Name, "PauseAtLastMark")) PauseAtLastMark = atoi(Value);
700  else if (!strcasecmp(Name, "AdaptiveSkipInitial")) AdaptiveSkipInitial= atoi(Value);
701  else if (!strcasecmp(Name, "AdaptiveSkipTimeout")) AdaptiveSkipTimeout= atoi(Value);
702  else if (!strcasecmp(Name, "AdaptiveSkipAlternate")) AdaptiveSkipAlternate = atoi(Value);
703  else if (!strcasecmp(Name, "AdaptiveSkipPrevNext")) AdaptiveSkipPrevNext = atoi(Value);
704  else if (!strcasecmp(Name, "SkipSeconds")) SkipSeconds = atoi(Value);
705  else if (!strcasecmp(Name, "SkipSecondsRepeat")) SkipSecondsRepeat = atoi(Value);
706  else if (!strcasecmp(Name, "ResumeID")) ResumeID = atoi(Value);
707  else if (!strcasecmp(Name, "CurrentChannel")) CurrentChannel = atoi(Value);
708  else if (!strcasecmp(Name, "CurrentVolume")) CurrentVolume = atoi(Value);
709  else if (!strcasecmp(Name, "CurrentDolby")) CurrentDolby = atoi(Value);
710  else if (!strcasecmp(Name, "InitialChannel")) InitialChannel = Value;
711  else if (!strcasecmp(Name, "VolumeSteps")) VolumeSteps = atoi(Value);
712  else if (!strcasecmp(Name, "VolumeLinearize")) VolumeLinearize = atoi(Value);
713  else if (!strcasecmp(Name, "InitialVolume")) InitialVolume = atoi(Value);
714  else if (!strcasecmp(Name, "DeviceBondings")) DeviceBondings = Value;
715  else if (!strcasecmp(Name, "ChannelsWrap")) ChannelsWrap = atoi(Value);
716  else if (!strcasecmp(Name, "ShowChannelNamesWithSource")) ShowChannelNamesWithSource = atoi(Value);
717  else if (!strcasecmp(Name, "EmergencyExit")) EmergencyExit = atoi(Value);
718  else if (!strcasecmp(Name, "LastReplayed")) cReplayControl::SetRecording(Value);
719  else
720  return false;
721  return true;
722 }
723 
724 bool cSetup::Save(void)
725 {
726  Store("OSDLanguage", OSDLanguage);
727  Store("OSDSkin", OSDSkin);
728  Store("OSDTheme", OSDTheme);
729  Store("WarEagleIcons", WarEagleIcons);
730  Store("PrimaryDVB", PrimaryDVB);
731  Store("ShowInfoOnChSwitch", ShowInfoOnChSwitch);
732  Store("TimeoutRequChInfo", TimeoutRequChInfo);
733  Store("MenuScrollPage", MenuScrollPage);
734  Store("MenuScrollWrap", MenuScrollWrap);
735  Store("MenuKeyCloses", MenuKeyCloses);
736  Store("MarkInstantRecord", MarkInstantRecord);
737  Store("NameInstantRecord", NameInstantRecord);
738  Store("InstantRecordTime", InstantRecordTime);
739  Store("LnbSLOF", LnbSLOF);
740  Store("LnbFrequLo", LnbFrequLo);
741  Store("LnbFrequHi", LnbFrequHi);
742  Store("DiSEqC", DiSEqC);
743  Store("UsePositioner", UsePositioner);
744  Store("SiteLat", SiteLat);
745  Store("SiteLon", SiteLon);
746  Store("PositionerSpeed", PositionerSpeed);
747  Store("PositionerSwing", PositionerSwing);
748  Store("PositionerLastLon", PositionerLastLon);
749  Store("SetSystemTime", SetSystemTime);
750  Store("TimeSource", cSource::ToString(TimeSource));
751  Store("TimeTransponder", TimeTransponder);
752  Store("StandardCompliance", StandardCompliance);
753  Store("MarginStart", MarginStart);
754  Store("MarginStop", MarginStop);
755  StoreLanguages("AudioLanguages", AudioLanguages);
756  Store("DisplaySubtitles", DisplaySubtitles);
757  StoreLanguages("SubtitleLanguages", SubtitleLanguages);
758  Store("SubtitleOffset", SubtitleOffset);
759  Store("SubtitleFgTransparency", SubtitleFgTransparency);
760  Store("SubtitleBgTransparency", SubtitleBgTransparency);
761  StoreLanguages("EPGLanguages", EPGLanguages);
762  Store("EPGScanTimeout", EPGScanTimeout);
763  Store("EPGBugfixLevel", EPGBugfixLevel);
764  Store("EPGLinger", EPGLinger);
765  Store("SVDRPTimeout", SVDRPTimeout);
766  Store("ZapTimeout", ZapTimeout);
767  Store("ChannelEntryTimeout",ChannelEntryTimeout);
768  Store("RcRepeatDelay", RcRepeatDelay);
769  Store("RcRepeatDelta", RcRepeatDelta);
770  Store("DefaultPriority", DefaultPriority);
771  Store("DefaultLifetime", DefaultLifetime);
772  Store("PauseKeyHandling", PauseKeyHandling);
773  Store("PausePriority", PausePriority);
774  Store("PauseLifetime", PauseLifetime);
775  Store("UseSubtitle", UseSubtitle);
776  Store("UseVps", UseVps);
777  Store("VpsMargin", VpsMargin);
778  Store("RecordingDirs", RecordingDirs);
779  Store("FoldersInTimerMenu", FoldersInTimerMenu);
780  Store("AlwaysSortFoldersFirst", AlwaysSortFoldersFirst);
781  Store("NumberKeysForChars", NumberKeysForChars);
782  Store("ColorKey0", ColorKey0);
783  Store("ColorKey1", ColorKey1);
784  Store("ColorKey2", ColorKey2);
785  Store("ColorKey3", ColorKey3);
786  Store("VideoDisplayFormat", VideoDisplayFormat);
787  Store("VideoFormat", VideoFormat);
788  Store("UpdateChannels", UpdateChannels);
789  Store("UseDolbyDigital", UseDolbyDigital);
790  Store("ChannelInfoPos", ChannelInfoPos);
791  Store("ChannelInfoTime", ChannelInfoTime);
792  Store("OSDLeftP", OSDLeftP);
793  Store("OSDTopP", OSDTopP);
794  Store("OSDWidthP", OSDWidthP);
795  Store("OSDHeightP", OSDHeightP);
796  Store("OSDLeft", OSDLeft);
797  Store("OSDTop", OSDTop);
798  Store("OSDWidth", OSDWidth);
799  Store("OSDHeight", OSDHeight);
800  Store("OSDAspect", OSDAspect);
801  Store("OSDMessageTime", OSDMessageTime);
802  Store("UseSmallFont", UseSmallFont);
803  Store("AntiAlias", AntiAlias);
804  Store("FontOsd", FontOsd);
805  Store("FontSml", FontSml);
806  Store("FontFix", FontFix);
807  Store("FontOsdSizeP", FontOsdSizeP);
808  Store("FontSmlSizeP", FontSmlSizeP);
809  Store("FontFixSizeP", FontFixSizeP);
810  Store("FontOsdSize", FontOsdSize);
811  Store("FontSmlSize", FontSmlSize);
812  Store("FontFixSize", FontFixSize);
813  Store("MaxVideoFileSize", MaxVideoFileSize);
814  Store("SplitEditedFiles", SplitEditedFiles);
815  Store("DelTimeshiftRec", DelTimeshiftRec);
816  Store("MinEventTimeout", MinEventTimeout);
817  Store("MinUserInactivity", MinUserInactivity);
818  Store("NextWakeupTime", NextWakeupTime);
819  Store("MultiSpeedMode", MultiSpeedMode);
820  Store("ShowReplayMode", ShowReplayMode);
821  Store("ShowRemainingTime", ShowRemainingTime);
822  Store("ProgressDisplayTime",ProgressDisplayTime);
823  Store("PauseOnMarkSet", PauseOnMarkSet);
824  Store("PauseOnMarkJump", PauseOnMarkJump);
825  Store("SkipEdited", SkipEdited);
826  Store("PauseAtLastMark", PauseAtLastMark);
827  Store("AdaptiveSkipInitial",AdaptiveSkipInitial);
828  Store("AdaptiveSkipTimeout",AdaptiveSkipTimeout);
829  Store("AdaptiveSkipAlternate", AdaptiveSkipAlternate);
830  Store("AdaptiveSkipPrevNext", AdaptiveSkipPrevNext);
831  Store("SkipSeconds", SkipSeconds);
832  Store("SkipSecondsRepeat", SkipSecondsRepeat);
833  Store("ResumeID", ResumeID);
834  Store("CurrentChannel", CurrentChannel);
835  Store("CurrentVolume", CurrentVolume);
836  Store("CurrentDolby", CurrentDolby);
837  Store("InitialChannel", InitialChannel);
838  Store("VolumeSteps", VolumeSteps);
839  Store("VolumeLinearize", VolumeLinearize);
840  Store("InitialVolume", InitialVolume);
841  Store("DeviceBondings", DeviceBondings);
842  Store("ChannelsWrap", ChannelsWrap);
843  Store("ShowChannelNamesWithSource", ShowChannelNamesWithSource);
844  Store("EmergencyExit", EmergencyExit);
845  Store("LastReplayed", cReplayControl::LastReplayed());
846 
847  Sort();
848 
850  isyslog("saved setup to %s", FileName());
851  return true;
852  }
853  return false;
854 }
cString dtoa(double d, const char *Format)
Converts the given double value to a string, making sure it uses a &#39;.
Definition: tools.c:378
static cString ToString(int Code)
Definition: sources.c:55
cSetupLine * Get(const char *Name, const char *Plugin=NULL)
Definition: config.c:505
bool Parse(FILE *f, cList< cNestedItem > *List, int &Line)
Definition: config.c:184
cString DeviceBondings
Definition: config.h:363
bool isempty(const char *s)
Definition: tools.c:297
cSetupLine(void)
Definition: config.c:306
bool Close(void)
Definition: tools.c:1672
char * plugin
Definition: config.h:230
char * name
Definition: config.h:231
void Add(cListObject *Object, cListObject *After=NULL)
Definition: tools.c:2014
bool Parse(const char *s)
Definition: config.c:34
char * stripspace(char *s)
Definition: tools.c:201
bool Write(FILE *f, cList< cNestedItem > *List, int Indent=0)
Definition: config.c:213
bool Open(void)
Definition: tools.c:1662
void Store(const char *Name, const char *Value, const char *Plugin=NULL, bool AllowMultiple=false)
Definition: config.c:516
#define TIMERMACRO_EPISODE
Definition: config.h:52
static cString sprintf(const char *fmt,...) __attribute__((format(printf
Definition: tools.c:1080
const char * DefaultFontSml
Definition: font.c:25
Definition: plugin.h:20
#define esyslog(a...)
Definition: tools.h:34
cNestedItemList Commands
Definition: config.c:275
char * strn0cpy(char *dest, const char *src, size_t n)
Definition: tools.c:131
#define LOG_ERROR_STR(s)
Definition: tools.h:39
bool Save(void)
Definition: config.c:724
#define MAXVOLUME
Definition: device.h:32
void SetSubItems(bool On)
Definition: config.c:162
#define MAXFONTNAME
Definition: font.h:17
double atod(const char *s)
Converts the given string, which is a floating point number using a &#39;.
Definition: tools.c:357
void SetText(const char *Text)
Definition: config.c:156
virtual ~cSetupLine()
Definition: config.c:318
cString ToString(void)
Definition: config.c:107
void I18nSetLocale(const char *Locale)
Sets the current locale to Locale.
Definition: i18n.c:170
bool LocalhostOnly(void)
Definition: config.c:282
char * Read(FILE *f)
Definition: tools.c:1398
cNestedItemList RecordingCommands
Definition: config.c:276
#define MAXVIDEOFILESIZEDEFAULT
Definition: recording.h:420
#define ChkDoublePlausibility(Variable, Default)
Definition: config.c:24
#define MALLOC(type, size)
Definition: tools.h:46
virtual void Clear(void)
Definition: tools.c:2087
cSatCableNumbers(int Size, const char *s=NULL)
Definition: config.c:69
static void SetRecording(const char *FileName)
Definition: menu.c:5240
#define MaxSkinName
Definition: config.h:60
#define TIMERMACRO_TITLE
Definition: config.h:51
bool Parse(char *s)
Definition: config.c:340
void AddSubItem(cNestedItem *Item)
Definition: config.c:148
virtual ~cNestedItem()
Definition: config.c:137
cSVDRPhosts SVDRPhosts
Definition: config.c:280
virtual int Compare(const cListObject &ListObject) const
Must return 0 if this object is equal to ListObject, a positive value if it is "greater", and a negative value if it is "smaller".
Definition: config.c:325
T * Next(const T *object) const
Definition: tools.h:495
uint32_t in_addr_t
Definition: config.h:74
void Clear(void)
Definition: config.c:227
#define MaxThemeName
Definition: config.h:61
virtual bool SetupParse(const char *Name, const char *Value)
Definition: plugin.c:105
cListObject * Next(void) const
Definition: tools.h:468
bool Parse(const char *Name, const char *Value)
Definition: config.c:597
#define DEFINSTRECTIME
Definition: config.h:49
bool FromString(const char *s)
Definition: config.c:81
cSVDRPhost(void)
Definition: config.c:28
bool IsLocalhost(void)
Definition: config.c:57
#define MAXLIFETIME
Definition: config.h:48
cList< cNestedItem > * SubItems(void)
Definition: config.h:198
cSetup Setup
Definition: config.c:372
Definition: config.h:245
in_addr_t mask
Definition: config.h:79
bool Accepts(in_addr_t Address)
Definition: config.c:62
int Size(void) const
Definition: tools.h:551
const char * I18nLanguageCode(int Language)
Returns the three letter language code of the given Language (which is an index as returned by I18nCu...
Definition: i18n.c:223
int __BeginData__
Definition: config.h:257
cNestedItem(const char *Text, bool WithSubItems=false)
Definition: config.c:131
static const char * LastReplayed(void)
Definition: menu.c:5250
cNestedItemList Folders
Definition: config.c:274
const char * DefaultFontFix
Definition: font.c:26
int __EndData__
Definition: config.h:361
void StoreLanguages(const char *Name, int *Values)
Definition: config.c:562
T * First(void) const
Definition: tools.h:492
int FirstDeviceIndex(int DeviceIndex) const
Returns the first device index (starting at 0) that uses the same sat cable number as the device with...
Definition: config.c:116
virtual int Compare(const cListObject &ListObject) const
Must return 0 if this object is equal to ListObject, a positive value if it is "greater", and a negative value if it is "smaller".
Definition: config.c:143
virtual ~cNestedItemList()
Definition: config.c:179
bool Load(const char *FileName)
Definition: config.c:537
const cStringList * I18nLanguages(void)
Returns the list of available languages.
Definition: i18n.c:201
static int FromString(const char *s)
Definition: sources.c:68
char * skipspace(const char *s)
Definition: tools.h:200
bool ParseLanguages(const char *Value, int *Values)
Definition: config.c:581
bool Save(FILE *f)
Definition: config.c:365
#define isyslog(a...)
Definition: tools.h:35
cSetup(void)
Definition: config.c:374
cSetup & operator=(const cSetup &s)
Definition: config.c:497
static cPlugin * GetPlugin(int Index)
Definition: plugin.c:457
cNestedItemList(void)
Definition: config.c:174
bool Acceptable(in_addr_t Address)
Definition: config.c:293
struct in_addr addr
Definition: config.h:78
bool Load(const char *FileName)
Definition: config.c:234
char * compactspace(char *s)
Definition: tools.c:213
char * Utf8Strn0Cpy(char *Dest, const char *Src, int n)
Copies at most n character bytes from Src to Dest, making sure that the resulting copy ends with a co...
Definition: tools.c:845
#define STANDARD_DVB
Definition: config.h:70
cString InitialChannel
Definition: config.h:362
const char * DefaultFontOsd
Definition: font.c:24
bool Save(void)
Definition: config.c:258
int I18nLanguageIndex(const char *Code)
Returns the index of the language with the given three letter language Code.
Definition: i18n.c:228
char * strreplace(char *s, char c1, char c2)
Definition: tools.c:139
~cSatCableNumbers()
Definition: config.c:76
Definition: tools.h:168