vdr 2.8.2
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 5.45 2026/06/01 18:53:25 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.8.2"
26#define VDRVERSNUM 20802 // Version * 10000 + Major * 100 + Minor
27
28// The plugin API's version number:
29
30#define APIVERSION "13"
31#define APIVERSNUM 30013
32
33// When loading plugins, VDR searches files by their APIVERSION, which
34// is different from VDRVERSION. APIVERSION is a plain number, incremented
35// only when there are changes to the plugin API. This allows compiled
36// plugins to work with newer versions of the core VDR as long as no
37// interfaces have changed. APIVERSNUM begins with "300.." for backwards
38// compatibility and can be used in #if preprocessor statements to handle
39// version dependent code.
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#define DEFRETENTIONTIME 0 // default deleted recording retention time (days)
49
50#define TIMERMACRO_TITLE "TITLE"
51#define TIMERMACRO_EPISODE "EPISODE"
52#define TIMERMACRO_BEFORE "{<}"
53#define TIMERMACRO_MATCH "{=}"
54#define TIMERMACRO_AFTER "{>}"
55
56#define TIMERPATTERN_AVOID "@"
57#define TIMERPATTERN_BEGIN "^"
58#define TIMERPATTERN_END "$"
59
60#define MINOSDWIDTH 480
61#define MAXOSDWIDTH 1920
62#define MINOSDHEIGHT 324
63#define MAXOSDHEIGHT 1200
64
65#define MaxFileName NAME_MAX // obsolete - use NAME_MAX directly instead!
66#define MaxSkinName 16
67#define MaxThemeName 16
68
69// Basically VDR works according to the DVB standard, but there are countries/providers
70// that use other standards, which in some details deviate from the DVB standard.
71// This makes it necessary to handle things differently in some areas, depending on
72// which standard is actually used. The following macros are used to distinguish
73// these cases (make sure to adjust cMenuSetupDVB::standardComplianceTexts accordingly
74// when adding a new standard):
75
76#define STANDARD_DVB 0
77#define STANDARD_ANSISCTE 1
78#define STANDARD_NORDIG 2
79
80// Automatic subtitles:
81
82#define SUBTITLES_NO 0
83#define SUBTITLES_ALWAYS 1
84#define SUBTITLES_REWIND 2
85
86typedef uint32_t in_addr_t; //XXX from /usr/include/netinet/in.h (apparently this is not defined on systems with glibc < 2.2)
87
88class cSVDRPhost : public cListObject {
89private:
90 struct in_addr addr;
92public:
93 cSVDRPhost(void);
94 bool Parse(const char *s);
95 bool IsLocalhost(void);
96 bool Accepts(in_addr_t Address);
97 };
98
100private:
101 int size;
102 int *array;
103public:
104 cSatCableNumbers(int Size, const char *s = NULL);
106 int Size(void) const { return size; }
107 int *Array(void) { return array; }
108 bool FromString(const char *s);
109 cString ToString(void);
110 int FirstDeviceIndex(int DeviceIndex) const;
116 };
117
118template<class T> class cConfig : public cList<T> {
119private:
120 char *fileName;
122 virtual void Clear(void) override
123 {
124 free(fileName);
125 fileName = NULL;
127 }
128public:
129 cConfig(const char *NeedsLocking = NULL): cList<T>(NeedsLocking) { fileName = NULL; }
130 virtual ~cConfig() override { free(fileName); }
131 const char *FileName(void) { return fileName; }
132 bool Load(const char *FileName = NULL, bool AllowComments = false, bool MustExist = false)
133 {
135 if (FileName) {
136 free(fileName);
137 fileName = strdup(FileName);
138 allowComments = AllowComments;
139 }
140 bool result = !MustExist;
141 if (fileName && access(fileName, F_OK) == 0) {
142 isyslog("loading %s", fileName);
143 FILE *f = fopen(fileName, "r");
144 if (f) {
145 char *s;
146 int line = 0;
147 cReadLine ReadLine;
148 result = true;
149 while ((s = ReadLine.Read(f)) != NULL) {
150 line++;
151 if (allowComments) {
152 char *p = strchr(s, '#');
153 if (p)
154 *p = 0;
155 }
156 stripspace(s);
157 if (!isempty(s)) {
158 T *l = new T;
159 if (l->Parse(s))
160 this->Add(l);
161 else {
162 esyslog("ERROR: error in %s, line %d", fileName, line);
163 delete l;
164 result = false;
165 }
166 }
167 }
168 fclose(f);
169 }
170 else {
172 result = false;
173 }
174 }
175 if (!result)
176 fprintf(stderr, "vdr: error while reading '%s'\n", fileName);
177 return result;
178 }
179 bool Save(void) const
180 {
181 bool result = true;
182 T *l = (T *)this->First();
184 if (f.Open()) {
185 while (l) {
186 if (!l->Save(f)) {
187 result = false;
188 break;
189 }
190 l = (T *)l->Next();
191 }
192 if (!f.Close())
193 result = false;
194 }
195 else
196 result = false;
197 return result;
198 }
199 };
200
201class cNestedItem : public cListObject {
202private:
203 char *text;
205public:
206 cNestedItem(const char *Text, bool WithSubItems = false);
207 virtual ~cNestedItem() override;
208 virtual int Compare(const cListObject &ListObject) const override;
209 const char *Text(void) const { return text; }
211 void AddSubItem(cNestedItem *Item);
212 void SetText(const char *Text);
213 void SetSubItems(bool On);
214 };
215
216class cNestedItemList : public cList<cNestedItem> {
217private:
218 char *fileName;
219 bool Parse(FILE *f, cList<cNestedItem> *List, int &Line);
220 bool Write(FILE *f, cList<cNestedItem> *List, int Indent = 0);
221public:
222 cNestedItemList(void);
223 virtual ~cNestedItemList() override;
224 virtual void Clear(void) override;
225 bool Load(const char *FileName);
226 bool Save(void);
227 };
228
229class cSVDRPhosts : public cConfig<cSVDRPhost> {
230public:
231 bool LocalhostOnly(void);
232 bool Acceptable(in_addr_t Address);
233 };
234
239
240class cSetupLine : public cListObject {
241private:
242 char *plugin;
243 char *name;
244 char *value;
245public:
246 cSetupLine(void);
247 cSetupLine(const char *Name, const char *Value, const char *Plugin = NULL);
248 virtual ~cSetupLine() override;
249 virtual int Compare(const cListObject &ListObject) const override;
250 const char *Plugin(void) { return plugin; }
251 const char *Name(void) { return name; }
252 const char *Value(void) { return value; }
253 bool Parse(char *s);
254 bool Save(FILE *f);
255 };
256
257class cSetup : public cConfig<cSetupLine> {
258 friend class cPlugin; // needs to be able to call Store()
259private:
260 void StoreLanguages(const char *Name, int *Values);
261 bool ParseLanguages(const char *Value, int *Values);
262 bool Parse(const char *Name, const char *Value);
263 cSetupLine *Get(const char *Name, const char *Plugin = NULL);
264 void Store(const char *Name, const char *Value, const char *Plugin = NULL, bool AllowMultiple = false);
265 void Store(const char *Name, int Value, const char *Plugin = NULL);
266 void Store(const char *Name, double &Value, const char *Plugin = NULL);
267public:
268 // Also adjust cMenuSetup (menu.c) when adding parameters here!
280 char NameInstantRecord[NAME_MAX + 1];
310 char SVDRPHostName[HOST_NAME_MAX];
311 char SVDRPDefaultHost[HOST_NAME_MAX];
339 double OSDAspect;
385 cSetup(void);
386 cSetup& operator= (const cSetup &s);
387 bool Load(const char *FileName);
388 bool Save(void);
389 };
390
391extern cSetup Setup;
392
393#endif //__CONFIG_H
bool Save(void) const
Definition config.h:179
virtual ~cConfig() override
Definition config.h:130
cConfig(const char *NeedsLocking=NULL)
Definition config.h:129
char * fileName
Definition config.h:120
const char * FileName(void)
Definition config.h:131
bool allowComments
Definition config.h:121
bool Load(const char *FileName=NULL, bool AllowComments=false, bool MustExist=false)
Definition config.h:132
virtual void Clear(void) override
Definition config.h:122
virtual void Clear(void)
Definition tools.c:2275
void Add(cListObject *Object, cListObject *After=NULL)
Definition tools.c:2198
cListObject(const cListObject &ListObject)
Definition tools.h:547
Definition tools.h:644
const T * First(void) const
Returns the first element in this list, or NULL if the list is empty.
Definition tools.h:656
cList(const char *NeedsLocking=NULL)
Sets up a new cList of the given type T.
Definition tools.h:646
bool Save(void)
Definition config.c:258
bool Write(FILE *f, cList< cNestedItem > *List, int Indent=0)
Definition config.c:213
virtual void Clear(void) override
Definition config.c:227
virtual ~cNestedItemList() override
Definition config.c:179
bool Parse(FILE *f, cList< cNestedItem > *List, int &Line)
Definition config.c:184
bool Load(const char *FileName)
Definition config.c:234
char * fileName
Definition config.h:218
cNestedItemList(void)
Definition config.c:174
void SetText(const char *Text)
Definition config.c:156
char * text
Definition config.h:203
void AddSubItem(cNestedItem *Item)
Definition config.c:148
void SetSubItems(bool On)
Definition config.c:162
virtual int Compare(const cListObject &ListObject) const override
Must return 0 if this object is equal to ListObject, a positive value if it is "greater",...
Definition config.c:143
virtual ~cNestedItem() override
Definition config.c:137
cNestedItem(const char *Text, bool WithSubItems=false)
Definition config.c:131
cList< cNestedItem > * SubItems(void)
Definition config.h:210
cList< cNestedItem > * subItems
Definition config.h:204
const char * Text(void) const
Definition config.h:209
char * Read(FILE *f)
Definition tools.c:1548
bool Parse(const char *s)
Definition config.c:34
in_addr_t mask
Definition config.h:91
bool IsLocalhost(void)
Definition config.c:57
cSVDRPhost(void)
Definition config.c:28
bool Accepts(in_addr_t Address)
Definition config.c:62
struct in_addr addr
Definition config.h:90
bool LocalhostOnly(void)
Definition config.c:282
bool Acceptable(in_addr_t Address)
Definition config.c:293
bool Open(void)
Definition tools.c:1782
bool Close(void)
Definition tools.c:1792
cSatCableNumbers(int Size, const char *s=NULL)
Definition config.c:69
int Size(void) const
Definition config.h:106
bool FromString(const char *s)
Definition config.c:81
int * Array(void)
Definition config.h:107
cString ToString(void)
Definition config.c:107
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 override
Must return 0 if this object is equal to ListObject, a positive value if it is "greater",...
Definition config.c:325
char * plugin
Definition config.h:242
const char * Name(void)
Definition config.h:251
cSetupLine(void)
Definition config.c:306
virtual ~cSetupLine() override
Definition config.c:318
bool Save(FILE *f)
Definition config.c:365
const char * Plugin(void)
Definition config.h:250
const char * Value(void)
Definition config.h:252
bool Parse(char *s)
Definition config.c:340
char * value
Definition config.h:244
char * name
Definition config.h:243
int __EndData__
Definition config.h:382
int DefaultLifetime
Definition config.h:317
int VolumeSteps
Definition config.h:374
int EmergencyExit
Definition config.h:381
int SplitEditedFiles
Definition config.h:353
int RcRepeatDelay
Definition config.h:314
int ColorKey3
Definition config.h:330
int MenuScrollPage
Definition config.h:276
int EPGBugfixLevel
Definition config.h:306
int ColorKey2
Definition config.h:330
int VideoDisplayFormat
Definition config.h:331
int SubtitleFgTransparency
Definition config.h:301
int MinUserInactivity
Definition config.h:355
int CurrentVolume
Definition config.h:373
int AntiAlias
Definition config.h:342
int FontFixSize
Definition config.h:351
int ShowInfoOnChSwitch
Definition config.h:274
int DeleteRetention
Definition config.h:316
int SkipSecondsRepeat
Definition config.h:370
int StandardCompliance
Definition config.h:295
char SVDRPDefaultHost[HOST_NAME_MAX]
Definition config.h:311
int CurrentChannel
Definition config.h:372
bool Save(void)
Definition config.c:742
int TimeoutRequChInfo
Definition config.h:275
int ResumeID
Definition config.h:371
char OSDTheme[MaxThemeName]
Definition config.h:272
int SubtitleLanguages[I18N_MAX_LANGUAGES+1]
Definition config.h:299
int SVDRPTimeout
Definition config.h:308
int OSDHeight
Definition config.h:338
int LnbSLOF
Definition config.h:282
int EPGLanguages[I18N_MAX_LANGUAGES+1]
Definition config.h:302
char OSDSkin[MaxSkinName]
Definition config.h:271
int UsePositioner
Definition config.h:286
int AlwaysSortFoldersFirst
Definition config.h:326
int AdaptiveSkipInitial
Definition config.h:365
int RecSortingDirection
Definition config.h:328
int VpsMargin
Definition config.h:323
double OSDAspect
Definition config.h:339
char OSDLanguage[I18N_MAX_LOCALE_LEN]
Definition config.h:270
int ShowChannelNamesWithSource
Definition config.h:379
int DefaultPriority
Definition config.h:317
int ZapTimeout
Definition config.h:312
double OSDWidthP
Definition config.h:337
int RecordKeyHandling
Definition config.h:318
int PauseKeyHandling
Definition config.h:319
double OSDHeightP
Definition config.h:337
int PositionerSpeed
Definition config.h:289
cSetup & operator=(const cSetup &s)
Definition config.c:506
int MarginStart
Definition config.h:296
bool Parse(const char *Name, const char *Value)
Definition config.c:606
double FontOsdSizeP
Definition config.h:346
int PauseAtLastMark
Definition config.h:364
int AdaptiveSkipPrevNext
Definition config.h:368
int FontOsdSize
Definition config.h:349
int LnbFrequLo
Definition config.h:283
bool Load(const char *FileName)
Definition config.c:546
friend class cPlugin
Definition config.h:258
int EPGPauseAfterScan
Definition config.h:304
int OpenRecMenuAtLastReplayed
Definition config.h:380
int FontSmlSize
Definition config.h:350
int UseSmallFont
Definition config.h:341
int SubtitleOffset
Definition config.h:300
int MarginStop
Definition config.h:296
cSetupLine * Get(const char *Name, const char *Plugin=NULL)
Definition config.c:514
int SVDRPPeering
Definition config.h:309
int ProgressDisplayTime
Definition config.h:360
int UpdateChannels
Definition config.h:333
int SkipSeconds
Definition config.h:369
int SubtitleBgTransparency
Definition config.h:301
int ColorKey0
Definition config.h:330
int FoldersInTimerMenu
Definition config.h:325
int MenuScrollWrap
Definition config.h:277
int EPGLinger
Definition config.h:307
int ShowReplayMode
Definition config.h:358
cSetup(void)
Definition config.c:374
int SiteLon
Definition config.h:288
int OSDTop
Definition config.h:338
int AdaptiveSkipAlternate
Definition config.h:367
int UseVps
Definition config.h:322
time_t NextWakeupTime
Definition config.h:356
void StoreLanguages(const char *Name, int *Values)
Definition config.c:571
int DisplaySubtitles
Definition config.h:298
bool ParseLanguages(const char *Value, int *Values)
Definition config.c:590
int ChannelInfoTime
Definition config.h:336
int SiteLat
Definition config.h:287
int VolumeLinearize
Definition config.h:375
int ChannelsWrap
Definition config.h:378
int EPGScanMaxChannel
Definition config.h:303
double FontFixSizeP
Definition config.h:348
int AudioLanguages[I18N_MAX_LANGUAGES+1]
Definition config.h:297
int OSDMessageTime
Definition config.h:340
int MarkInstantRecord
Definition config.h:279
double OSDLeftP
Definition config.h:337
int RecordingDirs
Definition config.h:324
int PausePriority
Definition config.h:320
double FontSmlSizeP
Definition config.h:347
int OSDLeft
Definition config.h:338
int AdaptiveSkipTimeout
Definition config.h:366
int MenuKeyCloses
Definition config.h:278
int DiSEqC
Definition config.h:285
char NameInstantRecord[NAME_MAX+1]
Definition config.h:280
char FontOsd[MAXFONTNAME]
Definition config.h:343
int UseSubtitle
Definition config.h:321
int OSDWidth
Definition config.h:338
int MinEventTimeout
Definition config.h:355
int ChannelInfoPos
Definition config.h:335
int LnbFrequHi
Definition config.h:284
void Store(const char *Name, const char *Value, const char *Plugin=NULL, bool AllowMultiple=false)
Definition config.c:525
char FontSml[MAXFONTNAME]
Definition config.h:344
int MultiSpeedMode
Definition config.h:357
int __BeginData__
Definition config.h:269
int EPGScanTimeout
Definition config.h:305
int TimeTransponder
Definition config.h:294
int VideoFormat
Definition config.h:332
int MaxVideoFileSize
Definition config.h:352
cString DeviceBondings
Definition config.h:384
int PositionerSwing
Definition config.h:290
double OSDTopP
Definition config.h:337
int PositionerLastLon
Definition config.h:291
int PauseOnMarkSet
Definition config.h:361
int DelTimeshiftRec
Definition config.h:354
int SetSystemTime
Definition config.h:292
int PrimaryDVB
Definition config.h:273
int ChannelEntryTimeout
Definition config.h:313
char FontFix[MAXFONTNAME]
Definition config.h:345
int TimeSource
Definition config.h:293
int UseDolbyDigital
Definition config.h:334
int PauseOnMarkJump
Definition config.h:362
int ColorKey1
Definition config.h:330
int ShowRemainingTime
Definition config.h:359
int CurrentDolby
Definition config.h:376
cString InitialChannel
Definition config.h:383
int DefaultSortModeRec
Definition config.h:327
char SVDRPHostName[HOST_NAME_MAX]
Definition config.h:310
int RcRepeatDelta
Definition config.h:315
int InstantRecordTime
Definition config.h:281
int NumberKeysForChars
Definition config.h:329
int SkipEdited
Definition config.h:363
int PauseLifetime
Definition config.h:320
int InitialVolume
Definition config.h:377
cNestedItemList Commands
Definition config.c:275
cSetup Setup
Definition config.c:372
cSVDRPhosts SVDRPhosts
Definition config.c:280
cNestedItemList Folders
Definition config.c:274
cNestedItemList RecordingCommands
Definition config.c:276
#define MaxSkinName
Definition config.h:66
uint32_t in_addr_t
Definition config.h:86
#define MaxThemeName
Definition config.h:67
#define MAXFONTNAME
Definition font.h:17
#define I18N_MAX_LOCALE_LEN
Definition i18n.h:17
#define I18N_MAX_LANGUAGES
Definition i18n.h:18
bool isempty(const char *s)
Definition tools.c:361
cString Indent(int n, const char *s)
Returns the given string s, preceeded with n blanks for indentation.
Definition tools.c:414
char * stripspace(char *s)
Definition tools.c:231
#define LOG_ERROR_STR(s)
Definition tools.h:40
#define esyslog(a...)
Definition tools.h:35
#define isyslog(a...)
Definition tools.h:36