Portability
authorChris Tallon <chris@vomp.tv>
Sat, 25 Mar 2006 18:44:35 +0000 (18:44 +0000)
committerChris Tallon <chris@vomp.tv>
Sat, 25 Mar 2006 18:44:35 +0000 (18:44 +0000)
defines.h
log.cc
log.h
vchannelselect.cc
vepgsettimer.cc
vlivebanner.cc
vrecordinglist.cc
vtimeredit.cc
vtimerlist.cc
vvideorec.cc

index 638943cfe9c05401fc4e5cccf91b8d7d00dee8f4..dcc5a89998809040ed465adf64cd40032c62e271 100644 (file)
--- 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 bc3d2ef38736b0684c51f823b9ad781056fd72d5..481e418556912f49a39b91737a358b8e1650f494 100644 (file)
--- 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 bf45f42d3c3c31b2a3e38d47d792f0b226dcb925..ff91243100013e7cf968a6d6de0807a96c698bfe 100644 (file)
--- a/log.h
+++ b/log.h
@@ -27,6 +27,7 @@
 #include <sys/time.h>
 #include <string.h>
 #include <stdarg.h>
+#include "defines.h"
 
 class Log
 {
index 37a0a4b8556c661e0d1be64b249743d672ceda7d..02ed78dc52119bc200ce322f6518275971acaaa3 100644 (file)
@@ -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;
index a185e6ece4258535eedbaa22a360f0eb0e0c0b27..a997fb9d77f72859bac822adaac49b528a3c63fc 100644 (file)
@@ -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);
index a973dca8901c9ae6e32a7a527f7a10d538721857..703a0707d077591f99e66017ff39a63e91fce445 100644 (file)
@@ -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;
     }
index 8fc3948c7d29c0f1489dd0133e5e7892b978f257..23a39bf41c6d0890370b49a0ae52d5db7e410a5c 100644 (file)
@@ -99,7 +99,7 @@ void VRecordingList::drawData()
   for (i = recDir->dirList.begin(); i != recDir->dirList.end(); i++)
   {
     dir = *i;
-    snprintf(tempA, 299, tr("<dir> %lu\t%s"), dir->getNumRecordings(), dir->name);
+    SNPRINTF(tempA, 299, tr("<dir> %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
index a6929fea7d4f4e718b7d564d2b790d3c979316b5..4c75c0d8f44c3fbbb28713aaa8539c4b2ea32ae8 100644 (file)
@@ -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();
 
index ad25bc95704c1aca12bc5bb758dd9f67395e4f0a..69fea672e7788cc8544b44371018b333c877de6b 100644 (file)
@@ -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;
   }
index d8d5b16d20b1be79eac1d14d85a8b0a94ae52ae3..dfcd34dffb216e9cff107868d784beafc7fd5bc0 100644 (file)
@@ -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);