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