summaryrefslogtreecommitdiff
path: root/config.h
diff options
context:
space:
mode:
Diffstat (limited to 'config.h')
-rw-r--r--config.h73
1 files changed, 42 insertions, 31 deletions
diff --git a/config.h b/config.h
index db3f1ed..277e957 100644
--- a/config.h
+++ b/config.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: config.h 1.34 2000/11/18 13:25:53 kls Exp $
+ * $Id: config.h 1.38 2001/01/14 15:29:27 kls Exp $
*/
#ifndef __CONFIG_H
@@ -14,11 +14,12 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
+#include <unistd.h>
#include "dvbapi.h"
#include "eit.h"
#include "tools.h"
-#define VDRVERSION "0.68"
+#define VDRVERSION "0.70"
#define MaxBuffer 10000
@@ -42,6 +43,15 @@ enum eKeys { // "Up" and "Down" must be the first two keys!
k_Flags = k_Repeat | k_Release,
};
+// This is in preparation for having more key codes:
+#define kMarkToggle k0
+#define kMarkMoveBack k4
+#define kMarkMoveForward k6
+#define kMarkJumpBack k7
+#define kMarkJumpForward k9
+#define kEditCut k2
+#define kEditTest k8
+
#define RAWKEY(k) ((k) & ~k_Flags)
#define ISRAWKEY(k) ((k) != kNone && ((k) & k_Flags) == 0)
#define NORMALKEY(k) ((k) & ~k_Repeat)
@@ -157,43 +167,45 @@ private:
cList<T>::Clear();
}
public:
+ cConfig(void) { fileName = NULL; }
+ virtual ~cConfig() { delete fileName; }
virtual bool Load(const char *FileName)
{
- isyslog(LOG_INFO, "loading %s", FileName);
- bool result = true;
Clear();
fileName = strdup(FileName);
- FILE *f = fopen(fileName, "r");
- if (f) {
- int line = 0;
- char buffer[MaxBuffer];
- while (fgets(buffer, sizeof(buffer), f) > 0) {
- line++;
- T *l = new T;
- if (l->Parse(buffer))
- Add(l);
- else {
- esyslog(LOG_ERR, "error in %s, line %d\n", fileName, line);
- delete l;
- result = false;
- break;
+ bool result = false;
+ if (access(FileName, F_OK) == 0) {
+ isyslog(LOG_INFO, "loading %s", FileName);
+ FILE *f = fopen(fileName, "r");
+ if (f) {
+ int line = 0;
+ char buffer[MaxBuffer];
+ result = true;
+ while (fgets(buffer, sizeof(buffer), f) > 0) {
+ line++;
+ T *l = new T;
+ if (l->Parse(buffer))
+ Add(l);
+ else {
+ esyslog(LOG_ERR, "error in %s, line %d\n", fileName, line);
+ delete l;
+ result = false;
+ break;
+ }
}
- }
- fclose(f);
- }
- else {
- LOG_ERROR_STR(fileName);
- result = false;
+ fclose(f);
+ }
+ else
+ LOG_ERROR_STR(fileName);
}
return result;
}
bool Save(void)
{
- //TODO make backup copies???
bool result = true;
T *l = (T *)First();
- FILE *f = fopen(fileName, "w");
- if (f) {
+ cSafeFile f(fileName);
+ if (f.Open()) {
while (l) {
if (!l->Save(f)) {
result = false;
@@ -201,12 +213,10 @@ public:
}
l = (T *)l->Next();
}
- fclose(f);
+ f.Close();
}
- else {
- LOG_ERROR_STR(fileName);
+ else
result = false;
- }
return result;
}
};
@@ -258,6 +268,7 @@ public:
int SetSystemTime;
int MarginStart, MarginStop;
int EPGScanTimeout;
+ int CurrentChannel;
cSetup(void);
bool Load(const char *FileName);
bool Save(const char *FileName = NULL);