From 81e586d000373ec9357a9ab924457a732fbab15a Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 25 Mar 2006 18:44:35 +0000 Subject: [PATCH] Portability --- defines.h | 15 ++++++++------- log.cc | 6 +++--- log.h | 1 + vchannelselect.cc | 44 ++++++++++++++++++++++++++++++++++++++++---- vepgsettimer.cc | 2 +- vlivebanner.cc | 4 ++-- vrecordinglist.cc | 6 +++--- vtimeredit.cc | 10 +++++----- vtimerlist.cc | 2 +- vvideorec.cc | 2 +- 10 files changed, 65 insertions(+), 27 deletions(-) diff --git a/defines.h b/defines.h index 638943c..dcc5a89 100644 --- a/defines.h +++ b/defines.h @@ -30,14 +30,15 @@ typedef unsigned long long ULLONG; #define OPTIONTYPE_TEXT 1 #define OPTIONTYPE_INT 2 -//#define SCREENWIDTH 720 -//#define SCREENHEIGHT 576 -//#define SCREENHEIGHT 480 - -//extern int SCREENWIDTH; -//extern int SCREENHEIGHT; - ULLONG htonll(ULLONG a); ULLONG ntohll(ULLONG a); +#ifdef WIN32 +#define SNPRINTF _snprintf +#define VSNPRINTF _vsnprintf +#else +#define SNPRINTF snprintf +#define VSNPRINTF vsnprintf +#endif + #endif diff --git a/log.cc b/log.cc index bc3d2ef..481e418 100644 --- a/log.cc +++ b/log.cc @@ -99,7 +99,7 @@ int Log::log(char *fromModule, int level, char* message, ...) gettimeofday(&tv, NULL); struct tm* tms = localtime(&tv.tv_sec); spaceLeft -= strftime(buffer, spaceLeft, "%H:%M:%S.", tms); - spaceLeft -= snprintf(&buffer[150-spaceLeft], spaceLeft, "%06lu ", (unsigned long)tv.tv_usec); + spaceLeft -= SNPRINTF(&buffer[150-spaceLeft], spaceLeft, "%06lu ", (unsigned long)tv.tv_usec); char levelString[10]; @@ -113,11 +113,11 @@ int Log::log(char *fromModule, int level, char* message, ...) if (level == INFO) strcpy(levelString, "[info] "); if (level == DEBUG) strcpy(levelString, "[debug] "); - spaceLeft -= snprintf(&buffer[150-spaceLeft], spaceLeft, "%s %s - ", levelString, fromModule); + spaceLeft -= SNPRINTF(&buffer[150-spaceLeft], spaceLeft, "%s %s - ", levelString, fromModule); va_list ap; va_start(ap, message); - spaceLeft = vsnprintf(&buffer[150-spaceLeft], spaceLeft, message, ap); + spaceLeft = VSNPRINTF(&buffer[150-spaceLeft], spaceLeft, message, ap); va_end(ap); int messageLength = strlen(buffer); diff --git a/log.h b/log.h index bf45f42..ff91243 100644 --- a/log.h +++ b/log.h @@ -27,6 +27,7 @@ #include #include #include +#include "defines.h" class Log { diff --git a/vchannelselect.cc b/vchannelselect.cc index 37a0a4b..02ed78d 100644 --- a/vchannelselect.cc +++ b/vchannelselect.cc @@ -53,7 +53,16 @@ void VChannelSelect::draw() switch(first) { - case 0 ... 9: + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: { sprintf(text, "%i", first); drawText(text, 7, 5, Colour::LIGHTTEXT); @@ -68,7 +77,16 @@ void VChannelSelect::draw() switch(second) { - case 0 ... 9: + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: { sprintf(text, "%i", second); drawText(text, 20, 5, Colour::LIGHTTEXT); @@ -83,7 +101,16 @@ void VChannelSelect::draw() switch(third) { - case 0 ... 9: + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: { sprintf(text, "%i", third); drawText(text, 33, 5, Colour::LIGHTTEXT); @@ -103,7 +130,16 @@ int VChannelSelect::handleCommand(int command) { switch(command) { - case Remote::ZERO ... Remote::NINE: + case Remote::ZERO: + case Remote::ONE: + case Remote::TWO: + case Remote::THREE: + case Remote::FOUR: + case Remote::FIVE: + case Remote::SIX: + case Remote::SEVEN: + case Remote::EIGHT: + case Remote::NINE: { if (numGot == 2) first = second; second = third; diff --git a/vepgsettimer.cc b/vepgsettimer.cc index a185e6e..a997fb9 100644 --- a/vepgsettimer.cc +++ b/vepgsettimer.cc @@ -133,7 +133,7 @@ char* VEpgSetTimer::genTimerString() strcpy(eventTitle, event->title); for(UINT i=0; i < strlen(eventTitle); i++) if (eventTitle[i] == ':') eventTitle[i] = '|'; - snprintf(timerString, 1023, "%i:%lu:%s:%s:%s:%s:%s:%s:", + SNPRINTF(timerString, 1023, "%i:%lu:%s:%s:%s:%s:%s:%s:", flags, channel->number, dateString, startString, endString, priority, lifetime, eventTitle); diff --git a/vlivebanner.cc b/vlivebanner.cc index a973dca..703a070 100644 --- a/vlivebanner.cc +++ b/vlivebanner.cc @@ -93,7 +93,7 @@ void VLiveBanner::setChannel(Channel* tChannel) // get the data char ttitleText[100]; - snprintf(ttitleText, 99, "%03lu - %s", currentChannel->number, currentChannel->name); + SNPRINTF(ttitleText, 99, "%03lu - %s", currentChannel->number, currentChannel->name); setTitleText(ttitleText); eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number); @@ -118,7 +118,7 @@ void VLiveBanner::setChannel(Channel* tChannel) btime = localtime((time_t*)&event->time); strftime(tempString2, 299, "%0H:%0M ", btime); - snprintf(tempString, 299, "%s %s", tempString2, event->title); + SNPRINTF(tempString, 299, "%s %s", tempString2, event->title); event->index = sl.addOption(tempString, first); first = 0; } diff --git a/vrecordinglist.cc b/vrecordinglist.cc index 8fc3948..23a39bf 100644 --- a/vrecordinglist.cc +++ b/vrecordinglist.cc @@ -99,7 +99,7 @@ void VRecordingList::drawData() for (i = recDir->dirList.begin(); i != recDir->dirList.end(); i++) { dir = *i; - snprintf(tempA, 299, tr(" %lu\t%s"), dir->getNumRecordings(), dir->name); + SNPRINTF(tempA, 299, tr(" %lu\t%s"), dir->getNumRecordings(), dir->name); dir->index = sl.addOption(tempA, first); first = 0; } @@ -128,7 +128,7 @@ void VRecordingList::draw() char title[300]; if (myParent) { - snprintf(title, 299, tr("Recordings - %s"), recDir->name); + SNPRINTF(title, 299, tr("Recordings - %s"), recDir->name); setTitleText(title); } else @@ -140,7 +140,7 @@ void VRecordingList::draw() char freeSpace[50]; int gigFree = Directory::freeSpace / 1024; - snprintf(freeSpace, 49, tr("%lu%% used, %iGB free"), Directory::usedPercent, gigFree); + SNPRINTF(freeSpace, 49, tr("%lu%% used, %iGB free"), Directory::usedPercent, gigFree); drawTextRJ(freeSpace, 560, 5, Colour::LIGHTTEXT); // Symbols diff --git a/vtimeredit.cc b/vtimeredit.cc index a6929fe..4c75c0d 100644 --- a/vtimeredit.cc +++ b/vtimeredit.cc @@ -73,15 +73,15 @@ VTimerEdit::VTimerEdit(RecTimer* trt) drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight(); // Channel - snprintf(buffer, 999, "%lu", recTimer->channelNumber); + SNPRINTF(buffer, 999, "%lu", recTimer->channelNumber); drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight(); // Name - snprintf(buffer, 999, "%s", recTimer->getName()); + SNPRINTF(buffer, 999, "%s", recTimer->getName()); drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight(); // Directory - if (recTimer->getDirectory()) snprintf(buffer, 999, "%s", recTimer->getDirectory()); + if (recTimer->getDirectory()) SNPRINTF(buffer, 999, "%s", recTimer->getDirectory()); else strcpy(buffer, ""); drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight(); ypos += surface->getFontHeight(); @@ -97,11 +97,11 @@ VTimerEdit::VTimerEdit(RecTimer* trt) drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight(); // Priority - snprintf(buffer, 999, "%lu", recTimer->priority); + SNPRINTF(buffer, 999, "%lu", recTimer->priority); drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight(); // Lifetime - snprintf(buffer, 999, "%lu", recTimer->lifeTime); + SNPRINTF(buffer, 999, "%lu", recTimer->lifeTime); drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight(); ypos += surface->getFontHeight(); diff --git a/vtimerlist.cc b/vtimerlist.cc index ad25bc9..69fea67 100644 --- a/vtimerlist.cc +++ b/vtimerlist.cc @@ -125,7 +125,7 @@ void VTimerList::insertData() btime = localtime((time_t*)&recTimer->startTime); strftime(strA, 299, "%d/%m %H:%M ", btime); - snprintf(strB, 299, "%s\t%s", strA, recTimer->getName()); + SNPRINTF(strB, 299, "%s\t%s", strA, recTimer->getName()); recTimer->index = sl.addOption(strB, first); first = 0; } diff --git a/vvideorec.cc b/vvideorec.cc index d8d5b16..dfcd34d 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -394,7 +394,7 @@ void VVideoRec::drawBarClocks() } else { - snprintf(buffer, 99, "%01i:%02i:%02i / %01i:%02i:%02i", chours, cminutes, cseconds, ehours, eminutes, eseconds); + SNPRINTF(buffer, 99, "%01i:%02i:%02i / %01i:%02i:%02i", chours, cminutes, cseconds, ehours, eminutes, eseconds); } drawText(buffer, clocksRegion.x, clocksRegion.y, Colour::LIGHTTEXT); -- 2.39.5