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