Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: [PATCH] Extended svdrp command LSTE



There was a problem, that LSTE crashed VDR, when no EPG data was available. It should work better with this new version :)

Thomas
Common subdirectories: vdr-1.3.4/PLUGINS and vdr-1.3.4-LSTE/PLUGINS
diff -uP vdr-1.3.4/epg.c vdr-1.3.4-LSTE/epg.c
--- vdr-1.3.4/epg.c	2004-01-09 16:22:18.000000000 +0100
+++ vdr-1.3.4-LSTE/epg.c	2004-02-15 17:30:39.000000000 +0100
@@ -511,13 +511,26 @@
       }
 }
 
-void cSchedule::Dump(FILE *f, const char *Prefix) const
+void cSchedule::Dump(FILE *f, const char *Prefix, eDumpMode DumpMode, time_t AtTime) const
 {
   cChannel *channel = Channels.GetByChannelID(channelID, true);
+  if (AtTime < time(NULL))
+     AtTime = time(NULL);
   if (channel) {
+     const cEvent *p;
      fprintf(f, "%sC %s %s\n", Prefix, channel->GetChannelID().ToString(), channel->Name());
-     for (cEvent *p = events.First(); p; p = events.Next(p))
-        p->Dump(f, Prefix);
+     if (DumpMode == dmAll)
+        for (p = events.First(); p; p = events.Next(p))
+           p->Dump(f, Prefix);
+     else if (DumpMode == dmPresent)
+        if ((p = GetPresentEvent()) != NULL)
+           p->Dump(f, Prefix);
+     else if (DumpMode == dmFollowing)
+        if ((p = GetFollowingEvent()) != NULL)
+           p->Dump(f, Prefix);
+     else if (DumpMode == dmAtTime)
+        if ((p = GetEventAround(AtTime)) != NULL)
+           p->Dump(f, Prefix);
      fprintf(f, "%sc\n", Prefix);
      }
 }
@@ -640,13 +653,13 @@
   return false;
 }
 
-bool cSchedules::Dump(FILE *f, const char *Prefix)
+bool cSchedules::Dump(FILE *f, const char *Prefix, eDumpMode DumpMode, time_t AtTime)
 {
   cSchedulesLock SchedulesLock;
   cSchedules *s = (cSchedules *)Schedules(SchedulesLock);
   if (s) {
      for (cSchedule *p = s->First(); p; p = s->Next(p))
-         p->Dump(f, Prefix);
+         p->Dump(f, Prefix, DumpMode, AtTime);
      return true;
      }
   return false;
diff -uP vdr-1.3.4/epg.h vdr-1.3.4-LSTE/epg.h
--- vdr-1.3.4/epg.h	2004-01-09 16:21:05.000000000 +0100
+++ vdr-1.3.4-LSTE/epg.h	2004-02-15 16:10:10.000000000 +0100
@@ -19,6 +19,8 @@
 
 #define MAXEPGBUGFIXLEVEL 2
 
+enum eDumpMode { dmAll, dmPresent, dmFollowing, dmAtTime };
+
 class cSchedule;
 
 class cEvent : public cListObject {
@@ -94,7 +96,7 @@
   const cEvent *GetEventAround(time_t Time) const;
   const cEvent *GetEventNumber(int n) const { return events.Get(n); }
   int NumEvents(void) const { return events.Count(); }
-  void Dump(FILE *f, const char *Prefix = "") const;
+  void Dump(FILE *f, const char *Prefix = "", eDumpMode DumpMode = dmAll, time_t AtTime = 0) const;
   static bool Read(FILE *f, cSchedules *Schedules);
   };
 
@@ -125,7 +127,7 @@
   static void Cleanup(bool Force = false);
   static void ResetVersions(void);
   static bool ClearAll(void);
-  static bool Dump(FILE *f, const char *Prefix = "");
+  static bool Dump(FILE *f, const char *Prefix = "", eDumpMode DumpMode = dmAll, time_t AtTime = 0);
   static bool Read(FILE *f = NULL);
   cSchedule *AddSchedule(tChannelID ChannelID);
   const cSchedule *GetSchedule(tChannelID ChannelID) const;
Common subdirectories: vdr-1.3.4/libsi and vdr-1.3.4-LSTE/libsi
diff -uP vdr-1.3.4/svdrp.c vdr-1.3.4-LSTE/svdrp.c
--- vdr-1.3.4/svdrp.c	2004-01-31 11:13:50.000000000 +0100
+++ vdr-1.3.4-LSTE/svdrp.c	2004-02-15 16:12:06.000000000 +0100
@@ -714,9 +714,63 @@
   cSchedulesLock SchedulesLock;
   const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock);
   if (Schedules) {
+     const cSchedule* Schedule = NULL;
+     eDumpMode DumpMode = dmAll;
+     time_t AtTime = time(NULL);
+     if (*Option) {
+        char buf[strlen(Option) + 1];
+        char *p = strcpy(buf, Option);
+        const char *delim = " \t";
+        char *ChanName = strtok(p, delim);
+        if (strcasecmp(ChanName, "NOW") == 0)
+           DumpMode = dmPresent;
+        else if (strcasecmp(ChanName, "NEXT") == 0)
+           DumpMode = dmFollowing;
+        else if (strcasecmp(ChanName, "AT") == 0) {
+           DumpMode = dmAtTime;
+           if ((p = strtok(NULL, delim)) != NULL) {
+              if (isnumber(p))
+                 AtTime = strtol(p, NULL, 10);
+              }
+           }
+        else {
+           cChannel* Channel = NULL;
+           if (isnumber(ChanName))
+              Channel = Channels.GetByNumber(strtol(Option, NULL, 10));
+           else
+              Channel = Channels.GetByChannelID(tChannelID::FromString(Option));
+           if (Channel) {
+              Schedule = Schedules->GetSchedule(Channel->GetChannelID());
+              if (!Schedule) {
+                 Reply(555, "No schedule found");
+                 return;
+                 }
+              }
+           else {
+              Reply(555, "Channel \"%s\" not defined", Option);
+              return;
+              }
+           }
+        if ((p = strtok(NULL, delim)) != NULL) {
+           if (strcasecmp(p, "NOW") == 0)
+              DumpMode = dmPresent;
+           else if (strcasecmp(p, "NEXT") == 0)
+              DumpMode = dmFollowing;
+           else if (strcasecmp(p, "AT") == 0) {
+              DumpMode = dmAtTime;
+              if ((p = strtok(NULL, delim)) != NULL) {
+                 if (isnumber(p))
+                    AtTime = strtol(p, NULL, 10);
+                 }
+              }
+           }
+        }
      FILE *f = fdopen(file, "w");
      if (f) {
-        Schedules->Dump(f, "215-");
+        if (Schedule)
+           Schedule->Dump(f, "215-", DumpMode, AtTime);
+        else
+           Schedules->Dump(f, "215-", DumpMode, AtTime);
         fflush(f);
         Reply(215, "End of EPG data");
         // don't 'fclose(f)' here!

Home | Main Index | Thread Index