vdr  2.0.7
config.h
Go to the documentation of this file.
1 /*
2  * config.h: 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.h 2.76.1.8 2014/04/13 14:00:42 kls Exp $
8  */
9 
10 #ifndef __CONFIG_H
11 #define __CONFIG_H
12 
13 #include <arpa/inet.h>
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
17 #include <time.h>
18 #include <unistd.h>
19 #include "i18n.h"
20 #include "font.h"
21 #include "tools.h"
22 
23 // VDR's own version number:
24 
25 #define VDRVERSION "2.0.7"
26 #define VDRVERSNUM 20007 // Version * 10000 + Major * 100 + Minor
27 
28 // The plugin API's version number:
29 
30 #define APIVERSION "2.0.6"
31 #define APIVERSNUM 20006 // Version * 10000 + Major * 100 + Minor
32 
33 // When loading plugins, VDR searches them by their APIVERSION, which
34 // may be smaller than VDRVERSION in case there have been no changes to
35 // VDR header files since the last APIVERSION. This allows compiled
36 // plugins to work with newer versions of the core VDR as long as no
37 // VDR header files have changed.
38 
39 #define JUMPPLAYVERSNUM 110
40 
41 #define MAXPRIORITY 99
42 #define MINPRIORITY (-MAXPRIORITY)
43 #define LIVEPRIORITY 0 // priority used when selecting a device for live viewing
44 #define TRANSFERPRIORITY (LIVEPRIORITY - 1) // priority used for actual local Transfer Mode
45 #define IDLEPRIORITY (MINPRIORITY - 1) // priority of an idle device
46 #define MAXLIFETIME 99
47 #define DEFINSTRECTIME 180 // default instant recording time (minutes)
48 
49 #define TIMERMACRO_TITLE "TITLE"
50 #define TIMERMACRO_EPISODE "EPISODE"
51 
52 // The MainMenuHook Patch's version number:
53 #define MAINMENUHOOKSVERSION "1.0.1"
54 #define MAINMENUHOOKSVERSNUM 10001 // Version * 10000 + Major * 100 + Minor
55 
56 #define MINOSDWIDTH 480
57 #define MAXOSDWIDTH 1920
58 #define MINOSDHEIGHT 324
59 #define MAXOSDHEIGHT 1200
60 
61 #define MaxFileName NAME_MAX // obsolete - use NAME_MAX directly instead!
62 #define MaxSkinName 16
63 #define MaxThemeName 16
64 
65 // Basically VDR works according to the DVB standard, but there are countries/providers
66 // that use other standards, which in some details deviate from the DVB standard.
67 // This makes it necessary to handle things differently in some areas, depending on
68 // which standard is actually used. The following macros are used to distinguish
69 // these cases (make sure to adjust cMenuSetupDVB::standardComplianceTexts accordingly
70 // when adding a new standard):
71 
72 #define STANDARD_DVB 0
73 #define STANDARD_ANSISCTE 1
74 
75 typedef uint32_t in_addr_t; //XXX from /usr/include/netinet/in.h (apparently this is not defined on systems with glibc < 2.2)
76 
77 class cSVDRPhost : public cListObject {
78 private:
79  struct in_addr addr;
81 public:
82  cSVDRPhost(void);
83  bool Parse(const char *s);
84  bool IsLocalhost(void);
85  bool Accepts(in_addr_t Address);
86  };
87 
89 private:
90  int size;
91  int *array;
92 public:
93  cSatCableNumbers(int Size, const char *s = NULL);
95  int Size(void) const { return size; }
96  int *Array(void) { return array; }
97  bool FromString(const char *s);
98  cString ToString(void);
99  int FirstDeviceIndex(int DeviceIndex) const;
105  };
106 
107 template<class T> class cConfig : public cList<T> {
108 private:
109  char *fileName;
111  void Clear(void)
112  {
113  free(fileName);
114  fileName = NULL;
115  cList<T>::Clear();
116  }
117 public:
118  cConfig(void) { fileName = NULL; }
119  virtual ~cConfig() { free(fileName); }
120  const char *FileName(void) { return fileName; }
121  bool Load(const char *FileName = NULL, bool AllowComments = false, bool MustExist = false)
122  {
124  if (FileName) {
125  free(fileName);
126  fileName = strdup(FileName);
127  allowComments = AllowComments;
128  }
129  bool result = !MustExist;
130  if (fileName && access(fileName, F_OK) == 0) {
131  isyslog("loading %s", fileName);
132  FILE *f = fopen(fileName, "r");
133  if (f) {
134  char *s;
135  int line = 0;
136  cReadLine ReadLine;
137  result = true;
138  while ((s = ReadLine.Read(f)) != NULL) {
139  line++;
140  if (allowComments) {
141  char *p = strchr(s, '#');
142  if (p)
143  *p = 0;
144  }
145  stripspace(s);
146  if (!isempty(s)) {
147  T *l = new T;
148  if (l->Parse(s))
149  this->Add(l);
150  else {
151  esyslog("ERROR: error in %s, line %d", fileName, line);
152  delete l;
153  result = false;
154  }
155  }
156  }
157  fclose(f);
158  }
159  else {
160  LOG_ERROR_STR(fileName);
161  result = false;
162  }
163  }
164  if (!result)
165  fprintf(stderr, "vdr: error while reading '%s'\n", fileName);
166  return result;
167  }
168  bool Save(void)
169  {
170  bool result = true;
171  T *l = (T *)this->First();
172  cSafeFile f(fileName);
173  if (f.Open()) {
174  while (l) {
175  if (!l->Save(f)) {
176  result = false;
177  break;
178  }
179  l = (T *)l->Next();
180  }
181  if (!f.Close())
182  result = false;
183  }
184  else
185  result = false;
186  return result;
187  }
188  };
189 
190 class cNestedItem : public cListObject {
191 private:
192  char *text;
194 public:
195  cNestedItem(const char *Text, bool WithSubItems = false);
196  virtual ~cNestedItem();
197  virtual int Compare(const cListObject &ListObject) const;
198  const char *Text(void) const { return text; }
200  void AddSubItem(cNestedItem *Item);
201  void SetText(const char *Text);
202  void SetSubItems(bool On);
203  };
204 
205 class cNestedItemList : public cList<cNestedItem> {
206 private:
207  char *fileName;
208  bool Parse(FILE *f, cList<cNestedItem> *List, int &Line);
209  bool Write(FILE *f, cList<cNestedItem> *List, int Indent = 0);
210 public:
211  cNestedItemList(void);
212  virtual ~cNestedItemList();
213  void Clear(void);
214  bool Load(const char *FileName);
215  bool Save(void);
216  };
217 
218 class cSVDRPhosts : public cConfig<cSVDRPhost> {
219 public:
220  bool LocalhostOnly(void);
221  bool Acceptable(in_addr_t Address);
222  };
223 
224 extern cNestedItemList Folders;
228 extern cSVDRPhosts SVDRPhosts;
229 
230 class cSetupLine : public cListObject {
231 private:
232  char *plugin;
233  char *name;
234  char *value;
235 public:
236  cSetupLine(void);
237  cSetupLine(const char *Name, const char *Value, const char *Plugin = NULL);
238  virtual ~cSetupLine();
239  virtual int Compare(const cListObject &ListObject) const;
240  const char *Plugin(void) { return plugin; }
241  const char *Name(void) { return name; }
242  const char *Value(void) { return value; }
243  bool Parse(char *s);
244  bool Save(FILE *f);
245  };
246 
247 class cSetup : public cConfig<cSetupLine> {
248  friend class cPlugin; // needs to be able to call Store()
249 private:
250  void StoreLanguages(const char *Name, int *Values);
251  bool ParseLanguages(const char *Value, int *Values);
252  bool Parse(const char *Name, const char *Value);
253  cSetupLine *Get(const char *Name, const char *Plugin = NULL);
254  void Store(const char *Name, const char *Value, const char *Plugin = NULL, bool AllowMultiple = false);
255  void Store(const char *Name, int Value, const char *Plugin = NULL);
256  void Store(const char *Name, double &Value, const char *Plugin = NULL);
257 public:
258  // Also adjust cMenuSetup (menu.c) when adding parameters here!
270  char NameInstantRecord[NAME_MAX + 1];
272  int LnbSLOF;
275  int DiSEqC;
300  int UseVps;
315  double OSDAspect;
322  double FontOsdSizeP;
323  double FontSmlSizeP;
324  double FontFixSizeP;
339  int ResumeID;
340  int JumpPlay;
341  int PlayJump;
353  cSetup(void);
354  cSetup& operator= (const cSetup &s);
355  bool Load(const char *FileName);
356  bool Save(void);
357  };
358 
359 extern cSetup Setup;
360 
361 #endif //__CONFIG_H
cConfig(void)
Definition: config.h:118
int AntiAlias
Definition: config.h:318
cSetupLine * Get(const char *Name, const char *Plugin=NULL)
Definition: config.c:493
double OSDHeightP
Definition: config.h:313
bool Parse(FILE *f, cList< cNestedItem > *List, int &Line)
Definition: config.c:184
cNestedItemList Folders
Definition: config.c:274
cString DeviceBondings
Definition: config.h:352
int DumpNaluFill
Definition: config.h:331
int CurrentChannel
Definition: config.h:343
bool isempty(const char *s)
Definition: tools.c:248
const char * Text(void) const
Definition: config.h:198
int StandardCompliance
Definition: config.h:279
int MultiSpeedMode
Definition: config.h:334
cSetupLine(void)
Definition: config.c:307
double OSDWidthP
Definition: config.h:313
cNestedItemList Commands
Definition: config.c:275
bool Close(void)
Definition: tools.c:1603
char * plugin
Definition: config.h:232
char * name
Definition: config.h:233
double FontFixSizeP
Definition: config.h:324
cNestedItemList TimerCommands
Definition: config.c:277
void Add(cListObject *Object, cListObject *After=NULL)
Definition: tools.c:1945
const char * Name(void)
Definition: plugin.h:34
bool Parse(const char *s)
Definition: config.c:34
int UseVps
Definition: config.h:300
char * stripspace(char *s)
Definition: tools.c:176
bool Write(FILE *f, cList< cNestedItem > *List, int Indent=0)
Definition: config.c:213
double FontOsdSizeP
Definition: config.h:322
bool Open(void)
Definition: tools.c:1593
void Store(const char *Name, const char *Value, const char *Plugin=NULL, bool AllowMultiple=false)
Definition: config.c:504
#define I18N_MAX_LANGUAGES
Definition: i18n.h:18
char * text
Definition: config.h:192
int DefaultPriority
Definition: config.h:296
const char * Name(void)
Definition: config.h:241
int ZapTimeout
Definition: config.h:292
int PausePriority
Definition: config.h:297
Definition: plugin.h:20
virtual ~cConfig()
Definition: config.h:119
cNestedItemList RecordingCommands
Definition: config.c:276
#define esyslog(a...)
Definition: tools.h:34
int MinUserInactivity
Definition: config.h:332
int FontFixSize
Definition: config.h:327
char FontSml[MAXFONTNAME]
Definition: config.h:320
int AlwaysSortFoldersFirst
Definition: config.h:304
#define LOG_ERROR_STR(s)
Definition: tools.h:39
bool Save(void)
Definition: config.c:699
int EPGLanguages[I18N_MAX_LANGUAGES+1]
Definition: config.h:287
bool Load(const char *FileName=NULL, bool AllowComments=false, bool MustExist=false)
Definition: config.h:121
Definition: tools.h:479
int PauseLifetime
Definition: config.h:297
int MarkInstantRecord
Definition: config.h:269
void SetSubItems(bool On)
Definition: config.c:162
int RecordingDirs
Definition: config.h:302
int UseSubtitle
Definition: config.h:299
#define MAXFONTNAME
Definition: font.h:17
const char * Plugin(void)
Definition: config.h:240
int OSDTop
Definition: config.h:314
int EPGLinger
Definition: config.h:290
int ShowReplayMode
Definition: config.h:335
int MenuKeyCloses
Definition: config.h:268
void SetText(const char *Text)
Definition: config.c:156
virtual ~cSetupLine()
Definition: config.c:319
int ColorKey2
Definition: config.h:306
cString ToString(void)
Definition: config.c:107
int ShowInfoOnChSwitch
Definition: config.h:264
int CurrentDolby
Definition: config.h:345
const char * FileName(void)
Definition: config.h:120
bool LocalhostOnly(void)
Definition: config.c:283
int ChannelsWrap
Definition: config.h:347
int JumpPlay
Definition: config.h:340
char * Read(FILE *f)
Definition: tools.c:1329
int ChannelEntryTimeout
Definition: config.h:293
virtual void Clear(void)
Definition: tools.c:2018
cSatCableNumbers(int Size, const char *s=NULL)
Definition: config.c:69
#define MaxSkinName
Definition: config.h:62
char * fileName
Definition: config.h:207
int LnbFrequLo
Definition: config.h:273
int EmergencyExit
Definition: config.h:349
int TimeTransponder
Definition: config.h:278
bool Parse(char *s)
Definition: config.c:341
void AddSubItem(cNestedItem *Item)
Definition: config.c:148
virtual ~cNestedItem()
Definition: config.c:137
int NumberKeysForChars
Definition: config.h:305
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:326
int InitialVolume
Definition: config.h:346
char * value
Definition: config.h:234
uint32_t in_addr_t
Definition: config.h:75
char * fileName
Definition: config.h:109
void Clear(void)
Definition: config.c:227
int SubtitleFgTransparency
Definition: config.h:286
int ChannelInfoPos
Definition: config.h:311
bool Save(void)
Definition: config.h:168
#define MaxThemeName
Definition: config.h:63
double OSDLeftP
Definition: config.h:313
bool Parse(const char *Name, const char *Value)
Definition: config.c:585
bool FromString(const char *s)
Definition: config.c:81
cSVDRPhost(void)
Definition: config.c:28
char FontOsd[MAXFONTNAME]
Definition: config.h:319
int LnbSLOF
Definition: config.h:272
bool IsLocalhost(void)
Definition: config.c:57
int SVDRPTimeout
Definition: config.h:291
void Clear(void)
Definition: config.h:111
const char * Value(void)
Definition: config.h:242
int SubtitleLanguages[I18N_MAX_LANGUAGES+1]
Definition: config.h:284
int FoldersInTimerMenu
Definition: config.h:303
int TimeSource
Definition: config.h:277
cList< cNestedItem > * SubItems(void)
Definition: config.h:199
int EPGScanTimeout
Definition: config.h:288
int SubtitleOffset
Definition: config.h:285
int VideoFormat
Definition: config.h:308
int PauseKeyHandling
Definition: config.h:298
Definition: config.h:247
in_addr_t mask
Definition: config.h:80
int OSDLeft
Definition: config.h:314
bool Accepts(in_addr_t Address)
Definition: config.c:62
int SplitEditedFiles
Definition: config.h:329
int ColorKey3
Definition: config.h:306
int MinEventTimeout
Definition: config.h:332
int __BeginData__
Definition: config.h:259
int LnbFrequHi
Definition: config.h:274
cNestedItem(const char *Text, bool WithSubItems=false)
Definition: config.c:131
int ProgressDisplayTime
Definition: config.h:337
int RcRepeatDelay
Definition: config.h:294
int InstantRecordTime
Definition: config.h:271
int MaxVideoFileSize
Definition: config.h:328
cSVDRPhosts SVDRPhosts
Definition: config.c:281
int ChannelInfoTime
Definition: config.h:312
int __EndData__
Definition: config.h:350
int PrimaryDVB
Definition: config.h:263
int SetSystemTime
Definition: config.h:276
int VpsMargin
Definition: config.h:301
void StoreLanguages(const char *Name, int *Values)
Definition: config.c:550
int UseDolbyDigital
Definition: config.h:310
cSetup Setup
Definition: config.c:373
T * First(void) const
Definition: tools.h:482
char FontFix[MAXFONTNAME]
Definition: config.h:321
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
int MarginStop
Definition: config.h:280
int ShowChannelNamesWithSource
Definition: config.h:348
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
int AudioLanguages[I18N_MAX_LANGUAGES+1]
Definition: config.h:281
int ColorKey1
Definition: config.h:306
bool Load(const char *FileName)
Definition: config.c:525
time_t NextWakeupTime
Definition: config.h:333
double OSDAspect
Definition: config.h:315
int PauseOnMarkSet
Definition: config.h:338
int UpdateChannels
Definition: config.h:309
bool ParseLanguages(const char *Value, int *Values)
Definition: config.c:569
#define I18N_MAX_LOCALE_LEN
Definition: i18n.h:17
bool Save(FILE *f)
Definition: config.c:366
int DelTimeshiftRec
Definition: config.h:330
int TimeoutRequChInfo
Definition: config.h:265
cList< cNestedItem > * subItems
Definition: config.h:193
#define isyslog(a...)
Definition: tools.h:35
double FontSmlSizeP
Definition: config.h:323
cSetup(void)
Definition: config.c:375
int EPGBugfixLevel
Definition: config.h:289
int PlayJump
Definition: config.h:341
cSetup & operator=(const cSetup &s)
Definition: config.c:485
int CurrentVolume
Definition: config.h:344
int FontOsdSize
Definition: config.h:325
int UseSmallFont
Definition: config.h:317
cNestedItemList(void)
Definition: config.c:174
int ColorKey0
Definition: config.h:306
bool Acceptable(in_addr_t Address)
Definition: config.c:294
int * array
Definition: config.h:91
struct in_addr addr
Definition: config.h:79
int MenuScrollWrap
Definition: config.h:267
bool Load(const char *FileName)
Definition: config.c:234
int MenuScrollPage
Definition: config.h:266
char NameInstantRecord[NAME_MAX+1]
Definition: config.h:270
int * Array(void)
Definition: config.h:96
int SupportTeletext
Definition: config.h:283
int OSDHeight
Definition: config.h:314
int FontSmlSize
Definition: config.h:326
bool allowComments
Definition: config.h:110
int DisplaySubtitles
Definition: config.h:282
int VideoDisplayFormat
Definition: config.h:307
int OSDWidth
Definition: config.h:314
char OSDTheme[MaxThemeName]
Definition: config.h:262
cString InitialChannel
Definition: config.h:351
char OSDSkin[MaxSkinName]
Definition: config.h:261
bool Save(void)
Definition: config.c:258
int OSDMessageTime
Definition: config.h:316
int MarginStart
Definition: config.h:280
Definition: runvdr.c:107
int Size(void) const
Definition: config.h:95
char OSDLanguage[I18N_MAX_LOCALE_LEN]
Definition: config.h:260
int SubtitleBgTransparency
Definition: config.h:286
int PauseLastMark
Definition: config.h:342
int ResumeID
Definition: config.h:339
int RcRepeatDelta
Definition: config.h:295
~cSatCableNumbers()
Definition: config.c:76
Definition: tools.h:166
int DefaultLifetime
Definition: config.h:296
int ShowRemainingTime
Definition: config.h:336
double OSDTopP
Definition: config.h:313
int DiSEqC
Definition: config.h:275