summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitar Petrovski <dimeptr@gmail.com>2012-05-23 20:07:47 (GMT)
committerDimitar Petrovski <dimeptr@gmail.com>2012-05-23 20:07:47 (GMT)
commit7089617d8186143cfe946596dfafd650cb3028f9 (patch)
tree2614d69c4d9f7f765a893cddbba9bf0bae92df42
parent07e0eccce3b565fb13f2d675f6eddc38c4917b89 (diff)
downloadvdr-plugin-eepg-7089617d8186143cfe946596dfafd650cb3028f9.tar.gz
vdr-plugin-eepg-7089617d8186143cfe946596dfafd650cb3028f9.tar.bz2
move utilities to separate files
-rw-r--r--Makefile2
-rw-r--r--eepg.c110
-rw-r--r--equivhandler.c1
-rw-r--r--util.c113
-rw-r--r--util.h24
5 files changed, 140 insertions, 110 deletions
diff --git a/Makefile b/Makefile
index b020216..b63221f 100644
--- a/Makefile
+++ b/Makefile
@@ -65,7 +65,7 @@ DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
### The object files (add further files here):
-OBJS = $(PLUGIN).o dish.o epghandler.o setupeepg.o equivhandler.o
+OBJS = $(PLUGIN).o dish.o epghandler.o setupeepg.o equivhandler.o util.o
ifdef DBG
CXXFLAGS += -g
diff --git a/eepg.c b/eepg.c
index 91a08c0..337e93a 100644
--- a/eepg.c
+++ b/eepg.c
@@ -44,6 +44,7 @@
#include "log.h"
#include "setupeepg.h"
#include "equivhandler.h"
+#include "util.h"
#include <map>
#include <string>
@@ -168,8 +169,6 @@ unsigned int crc16 (unsigned int crc, unsigned char const *p, int len)
#define STARTTIME_BIAS (20*60)
-static int AvailableSources[32];
-static int NumberOfAvailableSources = 0;
static int LastVersionNagra = -1; //currently only used for Nagra, should be stored per transponder, per system
@@ -772,113 +771,6 @@ nextloop1:
//unsigned char DecodeErrorText[4096]; //TODO only used for debugging?
-int Yesterday;
-int YesterdayEpoch;
-int YesterdayEpochUTC;
-
-/*
- * Convert local time to UTC
- */
-time_t LocalTime2UTC (time_t t)
-{
- struct tm *temp;
-
- temp = gmtime (&t);
- temp->tm_isdst = -1;
- return mktime (temp);
-}
-
-/*
- * Convert UTC to local time
- */
-time_t UTC2LocalTime (time_t t)
-{
- return 2 * t - LocalTime2UTC (t);
-}
-
-void GetLocalTimeOffset (void)
-{
- time_t timeLocal;
- struct tm *tmCurrent;
-
- timeLocal = time (NULL);
- timeLocal -= 86400;
- tmCurrent = gmtime (&timeLocal);
- Yesterday = tmCurrent->tm_wday;
- tmCurrent->tm_hour = 0;
- tmCurrent->tm_min = 0;
- tmCurrent->tm_sec = 0;
- tmCurrent->tm_isdst = -1;
- YesterdayEpoch = mktime (tmCurrent);
- YesterdayEpochUTC = UTC2LocalTime (mktime (tmCurrent));
-}
-
-void CleanString (unsigned char *String)
-{
-
-// LogD (1, prep("Unclean: %s"), String);
- unsigned char *Src;
- unsigned char *Dst;
- int Spaces;
- int pC;
- Src = String;
- Dst = String;
- Spaces = 0;
- pC = 0;
- while (*Src) {
- // corrections
- if (*Src == 0x8c) { // iso-8859-2 LATIN CAPITAL LETTER S WITH ACUTE
- *Src = 0xa6;
- }
- if (*Src == 0x8f) { // iso-8859-2 LATIN CAPITAL LETTER Z WITH ACUTE
- *Src = 0xac;
- }
-
- if (*Src!=0x0A && *Src < 0x20) { //don't remove newline
- *Src = 0x20;
- }
- if (*Src == 0x20) {
- Spaces++;
- if (pC == 0) {
- Spaces++;
- }
- } else {
- Spaces = 0;
- }
- if (Spaces < 2) {
- *Dst = *Src;
- Dst++;
- pC++;
- }
- Src++;
- }
- if (Spaces > 0) {
- Dst--;
- *Dst = 0;
- } else {
- *Dst = 0;
- }
-// LogD (1, prep("Clean: %s"), String);
-}
-
-cChannel *GetChannelByID(tChannelID & channelID, bool searchOtherPos)
-{
- cChannel *VC = Channels.GetByChannelID(channelID, true);
- if(!VC && searchOtherPos){
- //look on other satpositions
- for(int i = 0;i < NumberOfAvailableSources;i++){
- channelID = tChannelID(AvailableSources[i], channelID.Nid(), channelID.Tid(), channelID.Sid());
- VC = Channels.GetByChannelID(channelID, true);
- if(VC){
- //found this actually on satellite nextdoor...
- break;
- }
- }
- }
-
- return VC;
-}
-
bool cFilterEEPG::GetThemesSKYBOX (void) //TODO can't we read this from the DVB stream?
{
string FileName = cSetupEEPG::getInstance()->getConfDir();
diff --git a/equivhandler.c b/equivhandler.c
index 3088027..3c99534 100644
--- a/equivhandler.c
+++ b/equivhandler.c
@@ -8,6 +8,7 @@
#include "equivhandler.h"
#include "setupeepg.h"
#include "log.h"
+#include "util.h"
#include <string>
diff --git a/util.c b/util.c
new file mode 100644
index 0000000..68708d7
--- /dev/null
+++ b/util.c
@@ -0,0 +1,113 @@
+/*
+ * util.c
+ *
+ * Created on: 23.5.2012
+ * Author: d.petrovski
+ */
+
+int NumberOfAvailableSources = 0;
+
+cChannel *GetChannelByID(tChannelID & channelID, bool searchOtherPos)
+{
+ cChannel *VC = Channels.GetByChannelID(channelID, true);
+ if(!VC && searchOtherPos){
+ //look on other satpositions
+ for(int i = 0;i < NumberOfAvailableSources;i++){
+ channelID = tChannelID(AvailableSources[i], channelID.Nid(), channelID.Tid(), channelID.Sid());
+ VC = Channels.GetByChannelID(channelID, true);
+ if(VC){
+ //found this actually on satellite nextdoor...
+ break;
+ }
+ }
+ }
+
+ return VC;
+}
+
+/*
+ * Convert local time to UTC
+ */
+time_t LocalTime2UTC (time_t t)
+{
+ struct tm *temp;
+
+ temp = gmtime (&t);
+ temp->tm_isdst = -1;
+ return mktime (temp);
+}
+
+/*
+ * Convert UTC to local time
+ */
+time_t UTC2LocalTime (time_t t)
+{
+ return 2 * t - LocalTime2UTC (t);
+}
+
+void GetLocalTimeOffset (void)
+{
+ time_t timeLocal;
+ struct tm *tmCurrent;
+
+ timeLocal = time (NULL);
+ timeLocal -= 86400;
+ tmCurrent = gmtime (&timeLocal);
+ Yesterday = tmCurrent->tm_wday;
+ tmCurrent->tm_hour = 0;
+ tmCurrent->tm_min = 0;
+ tmCurrent->tm_sec = 0;
+ tmCurrent->tm_isdst = -1;
+ YesterdayEpoch = mktime (tmCurrent);
+ YesterdayEpochUTC = UTC2LocalTime (mktime (tmCurrent));
+}
+
+void CleanString (unsigned char *String)
+{
+
+// LogD (1, prep("Unclean: %s"), String);
+ unsigned char *Src;
+ unsigned char *Dst;
+ int Spaces;
+ int pC;
+ Src = String;
+ Dst = String;
+ Spaces = 0;
+ pC = 0;
+ while (*Src) {
+ // corrections
+ if (*Src == 0x8c) { // iso-8859-2 LATIN CAPITAL LETTER S WITH ACUTE
+ *Src = 0xa6;
+ }
+ if (*Src == 0x8f) { // iso-8859-2 LATIN CAPITAL LETTER Z WITH ACUTE
+ *Src = 0xac;
+ }
+
+ if (*Src!=0x0A && *Src < 0x20) { //don't remove newline
+ *Src = 0x20;
+ }
+ if (*Src == 0x20) {
+ Spaces++;
+ if (pC == 0) {
+ Spaces++;
+ }
+ } else {
+ Spaces = 0;
+ }
+ if (Spaces < 2) {
+ *Dst = *Src;
+ Dst++;
+ pC++;
+ }
+ Src++;
+ }
+ if (Spaces > 0) {
+ Dst--;
+ *Dst = 0;
+ } else {
+ *Dst = 0;
+ }
+// LogD (1, prep("Clean: %s"), String);
+}
+
+
diff --git a/util.h b/util.h
new file mode 100644
index 0000000..a94390a
--- /dev/null
+++ b/util.h
@@ -0,0 +1,24 @@
+/*
+ * util.h
+ *
+ * Created on: 23.5.2012
+ * Author: d.petrovski
+ */
+
+#ifndef UTIL_H_
+#define UTIL_H_
+
+int AvailableSources[32];
+int NumberOfAvailableSources;
+
+int Yesterday;
+int YesterdayEpoch;
+int YesterdayEpochUTC;
+
+cChannel *GetChannelByID(tChannelID & channelID, bool searchOtherPos);
+time_t LocalTime2UTC (time_t t);
+time_t UTC2LocalTime (time_t t);
+void GetLocalTimeOffset (void);
+void CleanString (unsigned char *String);
+
+#endif /* UTIL_H_ */