Home

Dokumentation

Impressum

Dokumentation VDR
 

Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

config.h

Go to the documentation of this file.
00001 
00010 #ifndef __CONFIG_H
00011 #define __CONFIG_H
00012 
00013 #include <arpa/inet.h>
00014 #include <stdio.h>
00015 #include <stdlib.h>
00016 #include <string.h>
00017 #include <time.h>
00018 #include <unistd.h>
00019 #include "device.h"
00020 #include "tools.h"
00021 
00022 #define VDRVERSION "1.1.20"
00023 
00024 #define MAXPRIORITY 99
00025 #define MAXLIFETIME 99
00026 
00027 #define MINOSDWIDTH  40
00028 #define MAXOSDWIDTH  56
00029 #define MINOSDHEIGHT 12
00030 #define MAXOSDHEIGHT 21
00031 
00032 #define MaxFileName 256
00033 
00035 class cCommand : public cListObject {
00036 private:
00037   char *title;
00038   char *command;
00039   bool confirm;
00040   static char *result;
00041 public:
00042   cCommand(void);
00043   virtual ~cCommand();
00044   bool Parse(const char *s);
00045   const char *Title(void) { return title; }
00046   bool Confirm(void) { return confirm; }
00047   const char *Execute(const char *Parameters = NULL);
00048   };
00049 
00050 typedef uint32_t in_addr_t; //XXX from /usr/include/netinet/in.h (apparently this is not defined on systems with glibc < 2.2)
00051 
00052 
00054 class cSVDRPhost : public cListObject {
00055 private:
00056   struct in_addr addr;
00057   in_addr_t mask;
00058 public:
00059   cSVDRPhost(void);
00060   bool Parse(const char *s);
00061   bool Accepts(in_addr_t Address);
00062   };
00063 
00064 #define CACONFBASE 100
00065 
00067 class cCaDefinition : public cListObject {
00068 private:
00069   int number;
00070   char *description;
00071 public:
00072   cCaDefinition(void);
00073   ~cCaDefinition();
00074   bool Parse(const char *s);
00075   int Number(void) const { return number; }
00076   const char *Description(void) const { return description; }
00077   };
00078 
00079 
00081 template<class T> class cConfig : public cList<T> {
00082 private:
00083   char *fileName;
00084   bool allowComments;
00085   void Clear(void)
00086   {
00087     free(fileName);
00088     fileName = NULL;
00089     cList<T>::Clear();
00090   }
00091 public:
00092   cConfig(void) { fileName = NULL; }
00093   virtual ~cConfig() { free(fileName); }
00094   const char *FileName(void) { return fileName; }
00095   bool Load(const char *FileName = NULL, bool AllowComments = false)
00096   {
00097     Clear();
00098     if (FileName) {
00099        free(fileName);
00100        fileName = strdup(FileName);
00101        allowComments = AllowComments;
00102        }
00103     bool result = false;
00104     if (fileName && access(fileName, F_OK) == 0) {
00105        isyslog("loading %s", fileName);
00106        FILE *f = fopen(fileName, "r");
00107        if (f) {
00108           int line = 0;
00109           char buffer[MAXPARSEBUFFER];
00110           result = true;
00111           while (fgets(buffer, sizeof(buffer), f) > 0) {
00112                 line++;
00113                 if (allowComments) {
00114                    char *p = strchr(buffer, '#');
00115                    if (p)
00116                       *p = 0;
00117                    }
00118                 stripspace(buffer);
00119                 if (!isempty(buffer)) {
00120                    T *l = new T;
00121                    if (l->Parse(buffer))
00122                       Add(l);
00123                    else {
00124                       esyslog("ERROR: error in %s, line %d\n", fileName, line);
00125                       delete l;
00126                       result = false;
00127                       break;
00128                       }
00129                    }
00130                 }
00131           fclose(f);
00132           }
00133        else
00134           LOG_ERROR_STR(fileName);
00135        }
00136     return result;
00137   }
00138   bool Save(void)
00139   {
00140     bool result = true;
00141     T *l = (T *)First();
00142     cSafeFile f(fileName);
00143     if (f.Open()) {
00144        while (l) {
00145              if (!l->Save(f)) {
00146                 result = false;
00147                 break;
00148                 }
00149              l = (T *)l->Next();
00150              }
00151        if (!f.Close())
00152           result = false;
00153        }
00154     else
00155        result = false;
00156     return result;
00157   }
00158   };
00159 
00163 class cCommands : public cConfig<cCommand> {};
00164 
00165 
00167 class cSVDRPhosts : public cConfig<cSVDRPhost> {
00168 public:
00169   bool Acceptable(in_addr_t Address);
00170   };
00171 
00172 
00174 class cCaDefinitions : public cConfig<cCaDefinition> {
00175 public:
00176   const cCaDefinition *Get(int Number);
00177   };
00178 
00179 extern cCommands Commands;
00180 extern cCommands RecordingCommands;
00181 extern cSVDRPhosts SVDRPhosts;
00182 extern cCaDefinitions CaDefinitions;
00183 
00184 
00186 class cSetupLine : public cListObject {
00187 private:
00188   char *plugin;
00189   char *name;
00190   char *value;
00191 public:
00192   cSetupLine(void);
00193   cSetupLine(const char *Name, const char *Value, const char *Plugin = NULL);
00194   virtual ~cSetupLine();
00195   virtual bool operator< (const cListObject &ListObject);
00196   const char *Plugin(void) { return plugin; }
00197   const char *Name(void) { return name; }
00198   const char *Value(void) { return value; }
00199   bool Parse(char *s);
00200   bool Save(FILE *f);
00201   };
00202 
00203 
00205 class cSetup : public cConfig<cSetupLine> {
00206   friend class cPlugin;
00207   // needs to be able to call Store()
00208 
00209 private:
00210   void StoreCaCaps(const char *Name);
00211   bool ParseCaCaps(const char *Value);
00212   bool Parse(const char *Name, const char *Value);
00213   cSetupLine *Get(const char *Name, const char *Plugin = NULL);
00214   void Store(const char *Name, const char *Value, const char *Plugin = NULL, bool AllowMultiple = false);
00215   void Store(const char *Name, int Value, const char *Plugin = NULL);
00216 public:
00220   int __BeginData__;
00221   int OSDLanguage;
00222   int PrimaryDVB;
00223   int ShowInfoOnChSwitch;
00224   int MenuScrollPage;
00225   int MarkInstantRecord;
00226   char NameInstantRecord[MaxFileName];
00227   int InstantRecordTime;
00228   int LnbSLOF;
00229   int LnbFrequLo;
00230   int LnbFrequHi;
00231   int DiSEqC;
00232   int SetSystemTime;
00233   int TimeTransponder;
00234   int MarginStart, MarginStop;
00235   int EPGScanTimeout;
00236   int EPGBugfixLevel;
00237   int SVDRPTimeout;
00238   int SortTimers;
00239   int PrimaryLimit;
00240   int DefaultPriority, DefaultLifetime;
00241   int UseSubtitle;
00242   int RecordingDirs;
00243   int VideoFormat;
00244   int RecordDolbyDigital;
00245   int ChannelInfoPos;
00246   int OSDwidth, OSDheight;
00247   int OSDMessageTime;
00248   int MaxVideoFileSize;
00249   int SplitEditedFiles;
00250   int MinEventTimeout, MinUserInactivity;
00251   int MultiSpeedMode;
00252   int ShowReplayMode;
00253   int CaCaps[MAXDEVICES][MAXCACAPS];
00254   int CurrentChannel;
00255   int CurrentVolume;
00256   int __EndData__;
00257   cSetup(void);
00258   cSetup& operator= (const cSetup &s);
00259   bool Load(const char *FileName);
00260   bool Save(void);
00261   };
00262 
00263 extern cSetup Setup;
00264 
00265 #endif //__CONFIG_H
00266 

Generated on Wed Feb 5 23:30:07 2003 for VDR by doxygen1.3-rc2