From 89b9bbf5a17ceb9ce33ee0ee2c255968687b03b8 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Wed, 19 Feb 2020 20:16:18 +0000 Subject: [PATCH] 23 CWFs --- boxx.cc | 2 +- tcp.cc | 4 ++-- tcp.h | 4 ++-- vdr.cc | 48 ++++++++++++++++++++-------------------- vepg.cc | 2 +- vepglistadvanced.cc | 17 +++++++------- vrecordinglist.h | 4 +++- vrecordinglistadvanced.h | 2 ++ vrecordinglistclassic.h | 4 +++- vtimeredit.cc | 4 ++-- 10 files changed, 48 insertions(+), 43 deletions(-) diff --git a/boxx.cc b/boxx.cc index 071ba98..f3f6aff 100644 --- a/boxx.cc +++ b/boxx.cc @@ -293,7 +293,7 @@ int Boxx::drawPara(const char* text, int x, int y, const DrawStyle& colour, unsi if (osdv) charwidtharray = osdv->getCharWidthArray(); mbstate_t state; - memset((void*)&state, 0, sizeof(state)); + memset(&state, 0, sizeof(state)); while(1) { diff --git a/tcp.cc b/tcp.cc index 74eb7a3..de01ee1 100644 --- a/tcp.cc +++ b/tcp.cc @@ -323,9 +323,9 @@ int TCP::sendData(void* bufR, size_t count) return(count); } -int TCP::readData(UCHAR* buffer, int totalBytes) +int TCP::readData(void* targetBuffer, int totalBytes) { - + UCHAR* buffer = reinterpret_cast(targetBuffer); int bytesRead = 0; int thisRead; int readTries = 0; diff --git a/tcp.h b/tcp.h index 3b158eb..524cfea 100644 --- a/tcp.h +++ b/tcp.h @@ -57,8 +57,8 @@ class TCP int isConnected(); void disableTimeout(); - int readData(UCHAR* buffer, int totalBytes); - int sendData(void *, size_t size); + int readData(void* buffer, int totalBytes); + int sendData(void*, size_t size); static void dump(unsigned char* data, ULONG size); diff --git a/vdr.cc b/vdr.cc index b7a28c3..3f218b7 100644 --- a/vdr.cc +++ b/vdr.cc @@ -45,7 +45,7 @@ #include "tvmedia.h" #include -#define VOMP_PROTOCOLL_VERSION 0x00000500 +#define VOMP_PROTOCOL_VERSION 0x00000500 VDR* VDR::instance = NULL; #ifdef VOMP_MEDIAPLAYER @@ -336,7 +336,7 @@ void VDR::threadMethod() ULONG requestID; ULONG userDataLength; - UCHAR* userData; + void* userData; ULONG streamID; ULONG flag; @@ -352,7 +352,7 @@ void VDR::threadMethod() { timeNow = time(NULL); - readSuccess = tcp->readData((UCHAR*)&channelID, sizeof(ULONG)); // 2s timeout atm + readSuccess = tcp->readData(&channelID, sizeof(ULONG)); // 2s timeout atm if (!readSuccess) { @@ -394,21 +394,21 @@ void VDR::threadMethod() if (channelID == CHANNEL_REQUEST_RESPONSE) { - if (!tcp->readData((UCHAR*)&requestID, sizeof(ULONG))) break; + if (!tcp->readData(&requestID, sizeof(ULONG))) break; requestID = ntohl(requestID); - if (!tcp->readData((UCHAR*)&userDataLength, sizeof(ULONG))) break; + if (!tcp->readData(&userDataLength, sizeof(ULONG))) break; userDataLength = ntohl(userDataLength); if (userDataLength > 5000000) break; // how big can these packets get? userData = NULL; if (userDataLength > 0) { - userData = (UCHAR*)malloc(userDataLength); + userData = malloc(userDataLength); if (!userData) break; if (!tcp->readData(userData, userDataLength)) break; } vresp = new VDR_ResponsePacket(); - vresp->setResponse(requestID, userData, userDataLength); + vresp->setResponse(requestID, reinterpret_cast(userData), userDataLength); logger->log("VDR", Log::DEBUG, "Rxd a response packet, requestID=%lu, len=%lu", requestID, userDataLength); if (!edFindAndCall(vresp)) // makes ED lock, find receiver for vresp (using ed_cb_find() ) and then call (using ed_cb_call() ) @@ -420,24 +420,24 @@ void VDR::threadMethod() } else if (channelID == CHANNEL_STREAM || channelID == CHANNEL_TVMEDIA) { - if (!tcp->readData((UCHAR*)&streamID, sizeof(ULONG))) break; + if (!tcp->readData(&streamID, sizeof(ULONG))) break; streamID = ntohl(streamID); - if (!tcp->readData((UCHAR*)&flag, sizeof(ULONG))) break; + if (!tcp->readData(&flag, sizeof(ULONG))) break; flag = ntohl(flag); - if (!tcp->readData((UCHAR*)&userDataLength, sizeof(ULONG))) break; + if (!tcp->readData(&userDataLength, sizeof(ULONG))) break; userDataLength = ntohl(userDataLength); userData = NULL; if (userDataLength > 0) { - userData = (UCHAR*)malloc(userDataLength); + userData = malloc(userDataLength); if (!userData) break; if (!tcp->readData(userData, userDataLength)) break; } vresp = new VDR_ResponsePacket(); - vresp->setStream(streamID, flag, userData, userDataLength, channelID); + vresp->setStream(streamID, flag, reinterpret_cast(userData), userDataLength, channelID); //logger->log("VDR", Log::DEBUG, "Rxd a stream packet, streamID=%lu, flag=%lu, len=%lu", streamID, flag, userDataLength); if (!edFindAndCall(vresp)) // makes ED lock, find receiver for vresp (using ed_cb_find() ) and then call (using ed_cb_call() ) @@ -450,8 +450,8 @@ void VDR::threadMethod() else if (channelID == CHANNEL_KEEPALIVE) { ULONG KAreply = 0; - if (!tcp->readData((UCHAR*)&KAreply, sizeof(ULONG))) break; - KAreply = (ULONG)ntohl(KAreply); + if (!tcp->readData(&KAreply, sizeof(ULONG))) break; + KAreply = ntohl(KAreply); if (KAreply == lastKAsent) // successful KA response { lastKAsent = 0; @@ -493,7 +493,7 @@ void VDR::connectionDied() VDR_ResponsePacket* vresp; while(receivers.size()) { - vdrpr = (VDR_PacketReceiver*) *(receivers.begin()); + vdrpr = dynamic_cast(*(receivers.begin())); if (vdrpr->receiverChannel == CHANNEL_REQUEST_RESPONSE) { vresp = new VDR_ResponsePacket(); @@ -525,7 +525,7 @@ void VDR::connectionDied() edLock(); for(EDRL::iterator i = receivers.begin(); i != receivers.end(); i++) - if ((VDR_PacketReceiver*)*i == vdrpr) { receivers.erase(i); break; } + if (dynamic_cast(*i) == vdrpr) { receivers.erase(i); break; } } } edUnlock(); @@ -540,8 +540,8 @@ bool VDR::ed_cb_find(EDReceiver* edr, void* userTag) // edr is a VDR_PacketReceiver object made in VDR::RequestResponse // userTag is a VDR_ResponsePacket made in threadMethod - VDR_PacketReceiver* vdrpr = (VDR_PacketReceiver*)edr; - VDR_ResponsePacket* vresp = (VDR_ResponsePacket*)userTag; + VDR_PacketReceiver* vdrpr = dynamic_cast(edr); + VDR_ResponsePacket* vresp = reinterpret_cast(userTag); // Is vresp for vdrpr ? @@ -639,7 +639,7 @@ void VDR_PacketReceiver::call(void* userTag, bool& r_deregisterEDR, bool& r_wake // It's a RR. Save vresp and, signal the waiting thread and return. // VDR::RequestResponse will be blocking waiting for this to happen. // That function has a pointer to this object and can read save_vresp. - save_vresp = (VDR_ResponsePacket*)userTag; + save_vresp = reinterpret_cast(userTag); r_deregisterEDR = true; r_wakeThread = true; @@ -649,7 +649,7 @@ void VDR_PacketReceiver::call(void* userTag, bool& r_deregisterEDR, bool& r_wake { // It's a stream packet. Pass off the stream data to streamReceiver, // delete the vresp. Keep this PacketReceiver for the next stream packet. - VDR_ResponsePacket* vresp = (VDR_ResponsePacket*)userTag; + VDR_ResponsePacket* vresp = reinterpret_cast(userTag); streamReceiver->streamReceive(vresp->getFlag(), vresp->getUserData(), vresp->getUserDataLength()); delete vresp; @@ -665,7 +665,7 @@ void VDR_PacketReceiver::call(void* userTag, bool& r_deregisterEDR, bool& r_wake // but am going to try setting this to false because I don't know that there is a thread to signal // delete the EDR. It's made once per media requested and wasn't owned/deleted by anything before - VDR_ResponsePacket* vresp = (VDR_ResponsePacket*)userTag; + VDR_ResponsePacket* vresp = reinterpret_cast(userTag); Log::getInstance()->log("VDR", Log::DEBUG, "TVMedia Pictures arrived VDR %x", vresp->getStreamID()); OsdVector *osd=dynamic_cast(Osd::getInstance()); if (osd) osd->getPictReader()->receivePicture(vresp); @@ -703,7 +703,7 @@ int VDR::doLogin(unsigned int* v_server_min, unsigned int* v_server_max, unsigne *v_server_min=version_min; unsigned int version_max=vresp->extractULONG(); *v_server_max=version_max; - *v_client=VOMP_PROTOCOLL_VERSION; + *v_client=VOMP_PROTOCOL_VERSION; if (0x00000302 <= version_max) { unsigned int numlangcodes = vresp->extractULONG(); @@ -722,8 +722,8 @@ int VDR::doLogin(unsigned int* v_server_min, unsigned int* v_server_max, unsigne delete vresp; - if ((version_min > VOMP_PROTOCOLL_VERSION) - || (version_max < VOMP_PROTOCOLL_VERSION) ) { + if ((version_min > VOMP_PROTOCOL_VERSION) + || (version_max < VOMP_PROTOCOL_VERSION) ) { return 0; diff --git a/vepg.cc b/vepg.cc index 71609d0..4069109 100644 --- a/vepg.cc +++ b/vepg.cc @@ -219,7 +219,7 @@ void VEpg::setInfo(Event* event) 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; - LOCALTIME_R((time_t*)&eventtime, &btime); //get programme start time + LOCALTIME_R(&eventtime, &btime); //get programme start time #ifndef _MSC_VER strftime(timeString, 9, "%0H:%0M - ", &btime); // and format it as hh:mm - #else diff --git a/vepglistadvanced.cc b/vepglistadvanced.cc index cf0c574..742ccff 100644 --- a/vepglistadvanced.cc +++ b/vepglistadvanced.cc @@ -478,11 +478,11 @@ void VEpgListAdvanced::drawDataChannel(bool doIndexPop) time_t eventEndTime = (time_t)(currentEvent->time + currentEvent->duration); LOCALTIME_R(&eventStartTime, &btime); - strftime(tempA, 299, "%d/%m/%y %H:%M ", &btime); + strftime(tempA, 300, "%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); + strftime(tempB, 300, "- %H:%M ", &btime); + int check = SNPRINTF(tempC, 300, "\t %s\n \t \t%s%s", currentEvent->title,tempA,tempB); + if ((check < 0) || (check > 299)) Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "String too big"); // New TVMedia stuff TVMediaInfo *info= new TVMediaInfo(); info->setPosterThumb(channelNumber, currentEvent->id); @@ -545,12 +545,11 @@ void VEpgListAdvanced::drawDataNowNext(bool next, bool doIndexPop) time_t eventEndTime = (time_t)(currentEvent->time + currentEvent->duration); LOCALTIME_R(&eventStartTime, &btime); - strftime(tempA, 299, "%H:%M ", &btime); + strftime(tempA, 300, "%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); - + strftime(tempB, 300, "- %H:%M ", &btime); + int check = SNPRINTF(tempC, 300, "%s\n%s\t %s%s", currentEvent->title, chan->name,tempA,tempB); + if ((check < 0) || (check > 299)) Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "String too big"); } else { sprintf(tempC, "\n%s", chan->name); diff --git a/vrecordinglist.h b/vrecordinglist.h index 7f49b27..f9ec04e 100644 --- a/vrecordinglist.h +++ b/vrecordinglist.h @@ -42,7 +42,9 @@ class VRecordingList : public TBBoxx VRecordingList(); virtual ~VRecordingList(); - using TBBoxx::draw; +#ifndef WIN32 + using TBBoxx::draw; // Signal the compiler we are intentionally overriding the draw() virtual with different args +#endif virtual void draw(bool doIndexPop = false)=0; int handleCommand(int command); diff --git a/vrecordinglistadvanced.h b/vrecordinglistadvanced.h index c55edb6..f9dc189 100644 --- a/vrecordinglistadvanced.h +++ b/vrecordinglistadvanced.h @@ -30,7 +30,9 @@ class VRecordingListAdvanced : public VRecordingList VRecordingListAdvanced(); virtual ~VRecordingListAdvanced(); +#ifndef WIN32 using TBBoxx::draw; // Signal the compiler we are intentionally overriding the draw() virtual with different args +#endif void draw(bool doIndexPop = false); bool load(); diff --git a/vrecordinglistclassic.h b/vrecordinglistclassic.h index 2d056ca..ebd9156 100644 --- a/vrecordinglistclassic.h +++ b/vrecordinglistclassic.h @@ -28,7 +28,9 @@ class VRecordingListClassic : public VRecordingList VRecordingListClassic(); virtual ~VRecordingListClassic(); - using TBBoxx::draw; +#ifndef WIN32 + using TBBoxx::draw; // Signal the compiler we are intentionally overriding the draw() virtual with different args +#endif void draw(bool doIndexPop = false); bool load(); diff --git a/vtimeredit.cc b/vtimeredit.cc index da07870..0d2f97b 100644 --- a/vtimeredit.cc +++ b/vtimeredit.cc @@ -120,13 +120,13 @@ void VTimerEdit::draw() // Start time_t rectime = recTimer->startTime; - LOCALTIME_R((time_t*)&rectime, &tms); + LOCALTIME_R(&rectime, &tms); strftime(buffer, 999, "%d/%m %H:%M", &tms); drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight; // Stop rectime = recTimer->stopTime; - LOCALTIME_R((time_t*)&rectime, &tms); + LOCALTIME_R(&rectime, &tms); strftime(buffer, 999, "%d/%m %H:%M", &tms); drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight; -- 2.39.2