summaryrefslogtreecommitdiff
path: root/switchtimer.c
diff options
context:
space:
mode:
authorJohann Friedrichs <johann.friedrichs@web.de>2018-03-21 12:14:55 +0100
committerJohann Friedrichs <johann.friedrichs@web.de>2018-03-21 12:14:55 +0100
commite8a0e569152c50d6084f252d12854b8fd4e74466 (patch)
tree5a90ef7ea08ff2096df157ca109c5268cdc04903 /switchtimer.c
parent9c7d95ff8d6ba965cb23147507a859b1fd0491d6 (diff)
downloadvdr-plugin-epgsearch-e8a0e569152c50d6084f252d12854b8fd4e74466.tar.gz
vdr-plugin-epgsearch-e8a0e569152c50d6084f252d12854b8fd4e74466.tar.bz2
unified indentation
Diffstat (limited to 'switchtimer.c')
-rw-r--r--switchtimer.c178
1 files changed, 86 insertions, 92 deletions
diff --git a/switchtimer.c b/switchtimer.c
index b01172e..e69ed68 100644
--- a/switchtimer.c
+++ b/switchtimer.c
@@ -38,11 +38,10 @@ cSwitchTimer::cSwitchTimer(const cEvent* Event, int SwitchMinsBefore, int Mode,
{
eventID = 0;
startTime = 0;
- if (Event)
- {
- eventID = Event->EventID();
- channelID = Event->ChannelID();
- startTime = Event->StartTime();
+ if (Event) {
+ eventID = Event->EventID();
+ channelID = Event->ChannelID();
+ startTime = Event->StartTime();
}
switchMinsBefore = SwitchMinsBefore;
mode = Mode;
@@ -62,97 +61,94 @@ cSwitchTimer& cSwitchTimer::operator= (const cSwitchTimer &SwitchTimer)
bool cSwitchTimer::Parse(const char *s)
{
- char *line;
- char *pos;
- char *pos_next;
- int parameter = 1;
- int valuelen;
+ char *line;
+ char *pos;
+ char *pos_next;
+ int parameter = 1;
+ int valuelen;
#define MAXVALUELEN (10 * MaxFileName)
- char value[MAXVALUELEN];
- startTime=0;
-
- pos = line = strdup(s);
- pos_next = pos + strlen(pos);
- if (*pos_next == '\n') *pos_next = 0;
- while (*pos) {
- while (*pos == ' ') pos++;
- if (*pos) {
- if (*pos != ':') {
- pos_next = strchr(pos, ':');
- if (!pos_next)
- pos_next = pos + strlen(pos);
- valuelen = pos_next - pos + 1;
- if (valuelen > MAXVALUELEN)
- valuelen = MAXVALUELEN;
- strn0cpy(value, pos, valuelen);
- pos = pos_next;
- switch (parameter) {
- case 1:
- channelID = tChannelID::FromString(value);
- break;
- case 2:
- eventID = atoi(value);
- break;
- case 3:
- startTime = atol(value);
- break;
- case 4:
- switchMinsBefore = atoi(value);
- break;
- case 5:
- mode = atoi(value);
- break;
- case 6:
- unmute = atoi(value);
- break;
- default:
- break;
- } //switch
- }
- parameter++;
- }
- if (*pos) pos++;
- } //while
+ char value[MAXVALUELEN];
+ startTime = 0;
- free(line);
- return (parameter >= 3) ? true : false;
+ pos = line = strdup(s);
+ pos_next = pos + strlen(pos);
+ if (*pos_next == '\n') *pos_next = 0;
+ while (*pos) {
+ while (*pos == ' ') pos++;
+ if (*pos) {
+ if (*pos != ':') {
+ pos_next = strchr(pos, ':');
+ if (!pos_next)
+ pos_next = pos + strlen(pos);
+ valuelen = pos_next - pos + 1;
+ if (valuelen > MAXVALUELEN)
+ valuelen = MAXVALUELEN;
+ strn0cpy(value, pos, valuelen);
+ pos = pos_next;
+ switch (parameter) {
+ case 1:
+ channelID = tChannelID::FromString(value);
+ break;
+ case 2:
+ eventID = atoi(value);
+ break;
+ case 3:
+ startTime = atol(value);
+ break;
+ case 4:
+ switchMinsBefore = atoi(value);
+ break;
+ case 5:
+ mode = atoi(value);
+ break;
+ case 6:
+ unmute = atoi(value);
+ break;
+ default:
+ break;
+ } //switch
+ }
+ parameter++;
+ }
+ if (*pos) pos++;
+ } //while
+
+ free(line);
+ return (parameter >= 3) ? true : false;
}
const cEvent* cSwitchTimer::Event()
{
- time_t now = time(NULL);
- const cEvent* event = NULL;
- if (startTime > now)
- {
- LOCK_SCHEDULES_READ;
- if (!Schedules) return NULL;
- const cSchedule *Schedule = Schedules->GetSchedule(channelID);
- if (Schedule)
- {
- event = Schedule->GetEvent(eventID, startTime);
- if (!event)
- event = Schedule->GetEventAround(startTime);
- }
- }
- return event;
+ time_t now = time(NULL);
+ const cEvent* event = NULL;
+ if (startTime > now) {
+ LOCK_SCHEDULES_READ;
+ if (!Schedules) return NULL;
+ const cSchedule *Schedule = Schedules->GetSchedule(channelID);
+ if (Schedule) {
+ event = Schedule->GetEvent(eventID, startTime);
+ if (!event)
+ event = Schedule->GetEventAround(startTime);
+ }
+ }
+ return event;
}
cString cSwitchTimer::ToText(bool& ignore)
{
ignore = false;
- if (!Event())
- {
- ignore = true;
- return NULL;
+ if (!Event()) {
+ ignore = true;
+ return NULL;
}
LOCK_CHANNELS_READ;
const cChannel *channel = Channels->GetByChannelID(channelID, true, true);
if (!channel) return NULL;
cString buffer = cString::sprintf("%s:%u:%ld:%d:%d:%d",
- CHANNELSTRING(channel), eventID,
- startTime, switchMinsBefore,
- mode, unmute?1:0);
+ CHANNELSTRING(channel), eventID,
+ startTime, switchMinsBefore,
+ mode, unmute ? 1 : 0);
return buffer;
}
@@ -161,7 +157,7 @@ bool cSwitchTimer::Save(FILE *f)
bool ignore = false;
cString buffer = ToText(ignore);
if (!ignore)
- return fprintf(f, "%s\n", *buffer) > 0;
+ return fprintf(f, "%s\n", *buffer) > 0;
return true;
}
@@ -171,13 +167,12 @@ cSwitchTimer* cSwitchTimers::InSwitchList(const cEvent* event)
if (!event) return NULL;
cMutexLock SwitchTimersLock(this);
cSwitchTimer* switchTimer = SwitchTimers.First();
- while (switchTimer)
- {
- if (switchTimer->eventID == event->EventID() &&
- switchTimer->channelID == event->ChannelID() &&
- switchTimer->startTime == event->StartTime())
- return switchTimer;
- switchTimer = SwitchTimers.Next(switchTimer);
+ while (switchTimer) {
+ if (switchTimer->eventID == event->EventID() &&
+ switchTimer->channelID == event->ChannelID() &&
+ switchTimer->startTime == event->StartTime())
+ return switchTimer;
+ switchTimer = SwitchTimers.Next(switchTimer);
}
return NULL;
}
@@ -186,11 +181,10 @@ bool cSwitchTimers::Exists(const cSwitchTimer* SwitchTimer)
{
cMutexLock SwitchTimersLock(this);
cSwitchTimer* switchTimer = SwitchTimers.First();
- while (switchTimer)
- {
- if (switchTimer == SwitchTimer)
- return true;
- switchTimer = SwitchTimers.Next(switchTimer);
+ while (switchTimer) {
+ if (switchTimer == SwitchTimer)
+ return true;
+ switchTimer = SwitchTimers.Next(switchTimer);
}
return false;
}