#ifndef _MSC_VER
struct timeval tv;
gettimeofday(&tv, NULL);
- struct tm* tms = localtime(&tv.tv_sec);
+ struct tm tms;
+ localtime_r(&tv.tv_sec, &tms);
+ spaceLeft -= strftime(buffer, spaceLeft, "%H:%M:%S.", &tms);
+ spaceLeft -= SNPRINTF(&buffer[150-spaceLeft], spaceLeft, "%06lu ", (unsigned long)tv.tv_usec);
#else
struct _timeb tb;
_ftime(&tb);
struct tm* tms = localtime(&tb.time);
-#endif
spaceLeft -= strftime(buffer, spaceLeft, "%H:%M:%S.", tms);
-#ifndef _MSC_VER
- spaceLeft -= SNPRINTF(&buffer[150-spaceLeft], spaceLeft, "%06lu ", (unsigned long)tv.tv_usec);
-#else
spaceLeft -= SNPRINTF(&buffer[150-spaceLeft], spaceLeft, "%06lu ", (unsigned long)tb.millitm);
#endif
char * Media::getTimeString(char * buffer) const {
if (! buffer) buffer=new char[TIMEBUFLEN];
- struct tm ltime;
time_t tTime = (time_t)getTime();
- struct tm *btime = localtime(&tTime);
- memcpy(<ime,btime, sizeof(struct tm));
- btime=<ime;
- if (btime && tTime != 0) {
+ struct tm btime;
+ localtime_r(&tTime, &btime);
+
+ if (tTime != 0) {
#ifndef _MSC_VER
- strftime(buffer,TIMEBUFLEN, "%0g/%0m/%0d %0H:%0M ", btime);
+ strftime(buffer,TIMEBUFLEN, "%0g/%0m/%0d %0H:%0M ", &btime);
#else
- strftime(buffer,TIMEBUFLEN, "%Y/%m/%d %H:%M ", btime);
+ strftime(buffer,TIMEBUFLEN, "%Y/%m/%d %H:%M ", &btime);
#endif
}
void VEpg::setInfo(Event* event)
{
time_t t;
- struct tm* btime; // to hold programme start and end time
+ struct tm btime; // to hold programme start and end time
char timeString[9]; // to hold programme start and end time
int length = strlen(event->title); // calculate length of programme title string
char* title = new char[length + 15]; // create string to hold start time, end time and programme title
time_t eventtime = event->time;
- btime = localtime((time_t*)&eventtime); //get programme start time
+ localtime_r((time_t*)&eventtime, &btime); //get programme start time
#ifndef _MSC_VER
- strftime(timeString, 9, "%0H:%0M - ", btime); // and format it as hh:mm -
+ strftime(timeString, 9, "%0H:%0M - ", &btime); // and format it as hh:mm -
#else
- strftime(timeString, 9, "%H:%M - ", btime); // and format it as hh:mm -
+ strftime(timeString, 9, "%H:%M - ", &btime); // and format it as hh:mm -
#endif
strcpy(title, timeString); // put it in our buffer
t = event->time + event->duration; //get programme end time
- btime = localtime(&t);
+ localtime_r(&t, &btime);
#ifndef _MSC_VER
- strftime(timeString, 7, "%0H:%0M ", btime); // and format it as hh:mm -
+ strftime(timeString, 7, "%0H:%0M ", &btime); // and format it as hh:mm -
#else
- strftime(timeString, 7, "%H:%M ", btime); // and format it as hh:mm -
+ strftime(timeString, 7, "%H:%M ", &btime); // and format it as hh:mm -
#endif
strcat(title, timeString); // put it in our buffer
t = ltime;
- struct tm* tms;
- tms = localtime(&t);
- strftime(timeString, 19, "%a %d %b", tms);
+ struct tm tms;
+ localtime_r(&t, &tms);
+ strftime(timeString, 19, "%a %d %b", &tms);
int timey = chanListbox.getRootBoxOffsetY() - getFontHeight() - 3;
int timex = 135;
drawTextRJ(timeString, timex - 10, timey, DrawStyle::LIGHTTEXT); // print date
- strftime(timeString, 19, "%H:%M", tms);
+ strftime(timeString, 19, "%H:%M", &tms);
drawText(timeString, timex, timey, DrawStyle::LIGHTTEXT); // print left time
rectangle(155, timey + getFontHeight(), 2, 7, white);
t = t + 3600;
- tms = localtime(&t);
- strftime(timeString, 19, "%H:%M", tms);
+ localtime_r(&t, &tms);
+ strftime(timeString, 19, "%H:%M", &tms);
drawText(timeString, timex + 180, timey, DrawStyle::LIGHTTEXT); // print middle time
rectangle(335, timey + getFontHeight(), 2, 7, white);
t = t + 3600;
- tms = localtime(&t);
- strftime(timeString, 19, "%H:%M", tms);
+ localtime_r(&t, &tms);
+ strftime(timeString, 19, "%H:%M", &tms);
drawText(timeString, timex + 360, timey, DrawStyle::LIGHTTEXT); // print right time
rectangle(515, timey + getFontHeight(), 2, 7, white);
// pointer to selTime
time_t VEpg::prevHour(time_t* t)
{
- struct tm* tms;
- tms = localtime(t);
- tms->tm_sec = 0;
- tms->tm_min = 0;
- return mktime(tms);
+ struct tm tms;
+ localtime_r(t, &tms);
+ tms.tm_sec = 0;
+ tms.tm_min = 0;
+ return mktime(&tms);
}
void VEpg::processMessage(Message* m)
char tempA[300]; // FIXME this is guesswork!
char tempB[300]; // FIXME
char tempC[300]; // FIXME
- struct tm* btime;
+ struct tm btime;
time_t eventStartTime = (time_t)currentEvent->time;
time_t eventEndTime = (time_t)(currentEvent->time + currentEvent->duration);
- btime = localtime(&eventStartTime);
- strftime(tempA, 299, "%d/%m/%y %H:%M ", btime);
- btime = localtime(&eventEndTime);
- strftime(tempB, 299, "- %H:%M ", btime);
+ localtime_r(&eventStartTime, &btime);
+ strftime(tempA, 299, "%d/%m/%y %H:%M ", &btime);
+ localtime_r(&eventEndTime, &btime);
+ strftime(tempB, 299, "- %H:%M ", &btime);
//#endif
sprintf(tempC, "\t %s\n \t \t%s%s", currentEvent->title,tempA,tempB);
// New TVMedia stuff
char tempA[300]; // FIXME this is guesswork!
char tempB[300]; // FIXME
char tempC[300]; // FIXME
- struct tm* btime;
+ struct tm btime;
time_t eventStartTime = (time_t)currentEvent->time;
time_t eventEndTime = (time_t)(currentEvent->time + currentEvent->duration);
- btime = localtime(&eventStartTime);
- strftime(tempA, 299, "%H:%M ", btime);
- btime = localtime(&eventEndTime);
- strftime(tempB, 299, "- %H:%M ", btime);
+ localtime_r(&eventStartTime, &btime);
+ strftime(tempA, 299, "%H:%M ", &btime);
+ localtime_r(&eventEndTime, &btime);
+ strftime(tempB, 299, "- %H:%M ", &btime);
//#endif
sprintf(tempC, "%s\n%s\t %s%s", currentEvent->title, chan->name,tempA,tempB);
char freeSpace[50];
- struct tm* btime;
+ struct tm btime;
time_t now;
time(&now);
- btime = localtime(&now);
- strftime(freeSpace, 299, "%d/%m/%y", btime);
+ localtime_r(&now, &btime);
+ strftime(freeSpace, 299, "%d/%m/%y", &btime);
drawTextRJ(freeSpace, getWidth(), 5, DrawStyle::LIGHTTEXT);
char* timerString = new char[1024];
// Other
- struct tm* btime;
+ struct tm btime;
int flags;
char dateString[20];
char startMargin[10];
else strcpy(startMargin, "5");
startTime = event->time - (atoi(startMargin) * 60);
- btime = localtime(&startTime);
- strftime(dateString, 19, "%Y-%m-%d", btime);
- strftime(startString, 9, "%H%M", btime);
+ localtime_r(&startTime, &btime);
+ strftime(dateString, 19, "%Y-%m-%d", &btime);
+ strftime(startString, 9, "%H%M", &btime);
char* endMarginConfig = vdr->configLoad("Timers", "End margin");
if (endMarginConfig)
else strcpy(endMargin, "5");
endTime = event->time + event->duration + (atoi(endMargin) * 60);
- btime = localtime(&endTime);
- strftime(endString, 9, "%H%M", btime);
+ localtime_r(&endTime, &btime);
+ strftime(endString, 9, "%H%M", &btime);
char* priorityConfig = vdr->configLoad("Timers", "Priority");
if (priorityConfig)
char fullString[20];
time_t t;
- struct tm* btime;
+ struct tm btime;
char timeString[10];
time_t eventtime = event->time;
- btime = localtime(&eventtime);
+ localtime_r(&eventtime, &btime);
#ifndef _MSC_VER
- strftime(timeString, 9, "%0H:%0M - ", btime); // and format it as hh:mm -
+ strftime(timeString, 9, "%0H:%0M - ", &btime); // and format it as hh:mm -
#else
- strftime(timeString, 9, "%H:%M - ", btime); // and format it as hh:mm -
+ strftime(timeString, 9, "%H:%M - ", &btime); // and format it as hh:mm -
#endif
strcpy(fullString, timeString); // put it in our buffer
t = event->time + event->duration; //get programme end time
- btime = localtime(&t);
+ localtime_r(&t, &btime);
#ifndef _MSC_VER
- strftime(timeString, 9, "%0H:%0M", btime); // and format it as hh:mm -
+ strftime(timeString, 9, "%0H:%0M", &btime); // and format it as hh:mm -
#else
- strftime(timeString, 9, "%H:%M", btime); // and format it as hh:mm -
+ strftime(timeString, 9, "%H:%M", &btime); // and format it as hh:mm -
#endif
strcat(fullString, timeString); // put it in our buffer
char timeString[20];
time_t t;
time(&t);
- struct tm* tms = localtime(&t);
- strftime(timeString, 19, "%H:%M", tms);
+ struct tm tms;
+ localtime_r(&t, &tms);
+ strftime(timeString, 19, "%H:%M", &tms);
drawText(timeString, barRegion.x + 624, barRegion.y + 12, DrawStyle::LIGHTTEXT);
// Draw clocks
char tempA[300]; // FIXME this is guesswork!
char tempB[300]; // FIXME
- struct tm* btime;
+ struct tm btime;
Directory* currentSubDir;
DirectoryList::iterator i;
{
currentRec = *j;
time_t recStartTime = (time_t)currentRec->getStartTime();
- btime = localtime(&recStartTime);
+ localtime_r(&recStartTime, &btime);
//NMT does not like this too!
//#ifndef _MSC_VER
-// strftime(tempA, 299, "%0d/%0m %0H:%0M ", btime);
+// strftime(tempA, 299, "%0d/%0m %0H:%0M ", &btime);
//#else
- strftime(tempA, 299, "%d/%m/%y %H:%M ", btime);
+ strftime(tempA, 299, "%d/%m/%y %H:%M ", &btime);
//#endif
sprintf(tempB, "%c\t%s\n \t%s", (currentRec->getNew() ? '*': ' '), currentRec->getProgName(),tempA);
// New TVMedia stuff
RecordingList::iterator j;
RecordingList & recList = toShowDir->recList;
char tempA[300];
- struct tm* btime;
+ struct tm btime;
for (j = recList.begin(); j != recList.end(); j++)
{
currentRec = *j;
time_t recStartTime = (time_t)currentRec->getStartTime();
- btime = localtime(&recStartTime);
- strftime(tempA, 299, "%d/%m/%y %H:%M ", btime);
+ localtime_r(&recStartTime, &btime);
+ strftime(tempA, 299, "%d/%m/%y %H:%M ", &btime);
description<< tempA <<" "<< std::string(currentRec->getProgName()) << "\n";
char tempA[300]; // FIXME this is guesswork!
char tempB[300]; // FIXME
- struct tm* btime;
+ struct tm btime;
Directory* currentSubDir;
DirectoryList::iterator i;
{
currentRec = *j;
time_t recStartTime = (time_t)currentRec->getStartTime();
- btime = localtime(&recStartTime);
+ localtime_r(&recStartTime, &btime);
//NMT does not like this too!
//#ifndef _MSC_VER
-// strftime(tempA, 299, "%0d/%0m %0H:%0M ", btime);
+// strftime(tempA, 299, "%0d/%0m %0H:%0M ", &btime);
//#else
- strftime(tempA, 299, "%d/%m %H:%M ", btime);
+ strftime(tempA, 299, "%d/%m %H:%M ", &btime);
//#endif
sprintf(tempB, "%s\t%c\t%s", tempA, (currentRec->getNew() ? '*': ' '), currentRec->getProgName());
// Temp
char buffer[1000];
- struct tm* tms;
+ struct tm tms;
xpos = 150;
ypos = 50;
// Start
time_t rectime = recTimer->startTime;
- tms = localtime((time_t*)&rectime);
- strftime(buffer, 999, "%d/%m %H:%M", tms);
+ localtime_r((time_t*)&rectime, &tms);
+ strftime(buffer, 999, "%d/%m %H:%M", &tms);
drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
// Stop
rectime = recTimer->startTime;
- tms = localtime((time_t*)&rectime);
- strftime(buffer, 999, "%d/%m %H:%M", tms);
+ localtime_r((time_t*)&rectime, &tms);
+ strftime(buffer, 999, "%d/%m %H:%M", &tms);
drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
// Priority
char strA[300];
char strB[300];
- struct tm* btime;
+ struct tm btime;
// FIXME all drawing stuff in this class and sl.clear somewhere?!
for (UINT i = 0; i < recTimerList->size(); i++)
{
recTimer = (*recTimerList)[i];
- time_t rectime = recTimer->startTime;
- btime = localtime((time_t*)&rectime);
- strftime(strA, 299, "%d/%m %H:%M ", btime);
+ time_t rectime = recTimer->startTime;
+ localtime_r((time_t*)&rectime, &btime);
+ strftime(strA, 299, "%d/%m %H:%M ", &btime);
SNPRINTF(strB, 299, "%s\t%s", strA, recTimer->getName());
sl.addOption(strB, (ULONG)recTimer, first);
first = 0;
char timeString[20];
time_t t;
time(&t);
- struct tm* tms = localtime(&t);
- strftime(timeString, 19, "%d/%m %H:%M:%S", tms);
+ struct tm tms;
+ localtime_r(&t, &tms);
+ strftime(timeString, 19, "%d/%m %H:%M:%S", &tms);
drawTextRJ(timeString, 560, 5, DrawStyle::LIGHTTEXT);
Timers::getInstance()->setTimerT(this, 1, t + 1);
char tempString[300];
char tempString2[300];
- struct tm* btime;
+ struct tm btime;
Event* event;
int eventListSize = eventList->size();
std::stringstream string;
event = (*eventList)[i];
time_t etime = event->time;
- btime = localtime(&etime);
+ localtime_r(&etime, &btime);
#ifndef _MSC_VER
- strftime(tempString2, 299, "%0H:%0M ", btime);
+ strftime(tempString2, 299, "%0H:%0M ", &btime);
#else
- strftime(tempString2, 299, "%H:%M ", btime);
+ strftime(tempString2, 299, "%H:%M ", &btime);
#endif
SNPRINTF(tempString, 299, "%s %s", tempString2, event->title);
string << tempString << "\n";
char timeString[20];
time_t t;
time(&t);
- struct tm* tms = localtime(&t);
- strftime(timeString, 19, "%H:%M", tms);
+ struct tm tms;
+ localtime_r(&t, &tms);
+ strftime(timeString, 19, "%H:%M", &tms);
clock.setText(timeString);
time_t dt = 60 - (t % 60); // seconds to the next minute
char timeString[20];
time_t t;
time(&t);
- struct tm* tms = localtime(&t);
- strftime(timeString, 19, "%H:%M", tms);
+ struct tm tms;
+ localtime_r(&t, &tms);
+ strftime(timeString, 19, "%H:%M", &tms);
drawText(timeString, barRegion.x + 624, barRegion.y + 12, DrawStyle::LIGHTTEXT);
ULLONG lenPTS=player->getLenPTS();
char timeString[20];
time_t t;
time(&t);
- struct tm* tms = localtime(&t);
- strftime(timeString, 19, "%H:%M", tms);
+ struct tm tms;
+ localtime_r(&t, &tms);
+ strftime(timeString, 19, "%H:%M", &tms);
drawText(timeString, barRegion.x + 624, barRegion.y + 12, DrawStyle::LIGHTTEXT);
// Draw clocks
char timeString[20];
time_t t;
time(&t);
- struct tm* tms = localtime(&t);
- strftime(timeString, 19, "%H:%M", tms);
+ struct tm tms;
+ localtime_r(&t, &tms);
+ strftime(timeString, 19, "%H:%M", &tms);
drawTextRJ(timeString, 450, 5, DrawStyle::LIGHTTEXT);
time_t dt = 60 - (t % 60); // seconds to the next minute