silenced warnings concerning asprintf (requested by Rolf Ahrenberg)

Modified Files:
	CONTRIBUTORS HISTORY server/connectionVTP.c server/setup.c
This commit is contained in:
schmirl 2009-10-13 06:38:47 +00:00
parent ac40edfd24
commit 73e30fd5ca
4 changed files with 54 additions and 61 deletions

View File

@ -36,6 +36,7 @@ Rolf Ahrenberg
for fixing PAT repacker version field for fixing PAT repacker version field
for improving LIMIKUUTIO and PARENTALRATING patch detection for improving LIMIKUUTIO and PARENTALRATING patch detection
for suggesting to include the charset in HTTP replies for suggesting to include the charset in HTTP replies
for requesting replacement of asprintf calls
Rantanen Teemu Rantanen Teemu
for providing vdr-incompletesections.diff for providing vdr-incompletesections.diff

View File

@ -1,6 +1,7 @@
VDR Plugin 'streamdev' Revision History VDR Plugin 'streamdev' Revision History
--------------------------------------- ---------------------------------------
- silenced warnings concerning asprintf (requested by Rolf Ahrenberg)
- don't update recordings list on CmdPLAY (reported by BBlack) - don't update recordings list on CmdPLAY (reported by BBlack)
- cleaned up common.h / common.c - cleaned up common.h / common.c
- dropped cStreamdevMenuSetupPage - dropped cStreamdevMenuSetupPage

View File

@ -1,5 +1,5 @@
/* /*
* $Id: connectionVTP.c,v 1.24 2009/09/30 10:10:40 schmirl Exp $ * $Id: connectionVTP.c,v 1.25 2009/10/13 06:38:47 schmirl Exp $
*/ */
#include "server/connectionVTP.h" #include "server/connectionVTP.h"
@ -50,7 +50,7 @@ private:
const cSchedule *m_Schedule; const cSchedule *m_Schedule;
const cEvent *m_Event; const cEvent *m_Event;
int m_Errno; int m_Errno;
char *m_Error; cString m_Error;
eStates m_State; eStates m_State;
bool m_Traverse; bool m_Traverse;
time_t m_ToTime; time_t m_ToTime;
@ -67,7 +67,6 @@ cLSTEHandler::cLSTEHandler(cConnectionVTP *Client, const char *Option):
m_Schedule(NULL), m_Schedule(NULL),
m_Event(NULL), m_Event(NULL),
m_Errno(0), m_Errno(0),
m_Error(NULL),
m_State(Channel), m_State(Channel),
m_Traverse(false), m_Traverse(false),
m_ToTime(0) m_ToTime(0)
@ -94,12 +93,12 @@ cLSTEHandler::cLSTEHandler(cConnectionVTP *Client, const char *Option):
attime = strtol(p, NULL, 10); attime = strtol(p, NULL, 10);
else { else {
m_Errno = 501; m_Errno = 501;
m_Error = strdup("Invalid time"); m_Error = "Invalid time";
break; break;
} }
} else { } else {
m_Errno = 501; m_Errno = 501;
m_Error = strdup("Missing time"); m_Error = "Missing time";
break; break;
} }
} }
@ -110,7 +109,7 @@ cLSTEHandler::cLSTEHandler(cConnectionVTP *Client, const char *Option):
fromtime = strtol(p, NULL, 10); fromtime = strtol(p, NULL, 10);
else { else {
m_Errno = 501; m_Errno = 501;
m_Error = strdup("Invalid time"); m_Error = "Invalid time";
break; break;
} }
if ((p = strtok_r(NULL, delim, &strtok_next)) != NULL) { if ((p = strtok_r(NULL, delim, &strtok_next)) != NULL) {
@ -120,19 +119,19 @@ cLSTEHandler::cLSTEHandler(cConnectionVTP *Client, const char *Option):
m_ToTime = strtol(p, NULL, 10); m_ToTime = strtol(p, NULL, 10);
else { else {
m_Errno = 501; m_Errno = 501;
m_Error = strdup("Invalid time"); m_Error = "Invalid time";
break; break;
} }
} else { } else {
m_Errno = 501; m_Errno = 501;
m_Error = strdup("Missing time"); m_Error = "Missing time";
break; break;
} }
} }
} }
} else { } else {
m_Errno = 501; m_Errno = 501;
m_Error = strdup("Missing time"); m_Error = "Missing time";
break; break;
} }
} else if (!m_Schedule) { } else if (!m_Schedule) {
@ -146,27 +145,27 @@ cLSTEHandler::cLSTEHandler(cConnectionVTP *Client, const char *Option):
m_Schedule = m_Schedules->GetSchedule(Channel->GetChannelID()); m_Schedule = m_Schedules->GetSchedule(Channel->GetChannelID());
if (!m_Schedule) { if (!m_Schedule) {
m_Errno = 550; m_Errno = 550;
m_Error = strdup("No schedule found"); m_Error = "No schedule found";
break; break;
} }
} else { } else {
m_Errno = 550; m_Errno = 550;
asprintf(&m_Error, "Channel \"%s\" not defined", p); m_Error = cString::sprintf("Channel \"%s\" not defined", p);
break; break;
} }
} else { } else {
m_Errno = 501; m_Errno = 501;
asprintf(&m_Error, "Unknown option: \"%s\"", p); m_Error = cString::sprintf("Unknown option: \"%s\"", p);
break; break;
} }
p = strtok_r(NULL, delim, &strtok_next); p = strtok_r(NULL, delim, &strtok_next);
} }
} else if (m_Schedules == NULL) { } else if (m_Schedules == NULL) {
m_Errno = 451; m_Errno = 451;
m_Error = strdup("EPG data is being modified, try again"); m_Error = "EPG data is being modified, try again";
} }
if (m_Error == NULL) { if (*m_Error == NULL) {
if (m_Schedule != NULL) if (m_Schedule != NULL)
m_Schedules = NULL; m_Schedules = NULL;
else if (m_Schedules != NULL) else if (m_Schedules != NULL)
@ -205,15 +204,13 @@ cLSTEHandler::cLSTEHandler(cConnectionVTP *Client, const char *Option):
cLSTEHandler::~cLSTEHandler() cLSTEHandler::~cLSTEHandler()
{ {
delete m_SchedulesLock; delete m_SchedulesLock;
if (m_Error != NULL)
free(m_Error);
} }
bool cLSTEHandler::Next(bool &Last) bool cLSTEHandler::Next(bool &Last)
{ {
if (m_Error != NULL) { if (*m_Error != NULL) {
Last = true; Last = true;
cString str(m_Error, true); cString str(m_Error);
m_Error = NULL; m_Error = NULL;
return m_Client->Respond(m_Errno, "%s", *str); return m_Client->Respond(m_Errno, "%s", *str);
} }
@ -361,7 +358,7 @@ private:
const cChannel *m_Channel; const cChannel *m_Channel;
char *m_Option; char *m_Option;
int m_Errno; int m_Errno;
char *m_Error; cString m_Error;
bool m_Traverse; bool m_Traverse;
public: public:
cLSTCHandler(cConnectionVTP *Client, const char *Option); cLSTCHandler(cConnectionVTP *Client, const char *Option);
@ -374,18 +371,17 @@ cLSTCHandler::cLSTCHandler(cConnectionVTP *Client, const char *Option):
m_Channel(NULL), m_Channel(NULL),
m_Option(NULL), m_Option(NULL),
m_Errno(0), m_Errno(0),
m_Error(NULL),
m_Traverse(false) m_Traverse(false)
{ {
if (!Channels.Lock(false, 500)) { if (!Channels.Lock(false, 500)) {
m_Errno = 451; m_Errno = 451;
m_Error = strdup("Channels are being modified - try again"); m_Error = "Channels are being modified - try again";
} else if (*Option) { } else if (*Option) {
if (isnumber(Option)) { if (isnumber(Option)) {
m_Channel = Channels.GetByNumber(strtol(Option, NULL, 10)); m_Channel = Channels.GetByNumber(strtol(Option, NULL, 10));
if (m_Channel == NULL) { if (m_Channel == NULL) {
m_Errno = 501; m_Errno = 501;
asprintf(&m_Error, "Channel \"%s\" not defined", Option); m_Error = cString::sprintf("Channel \"%s\" not defined", Option);
return; return;
} }
} else { } else {
@ -401,7 +397,7 @@ cLSTCHandler::cLSTCHandler(cConnectionVTP *Client, const char *Option):
if (i > Channels.MaxNumber()) { if (i > Channels.MaxNumber()) {
m_Errno = 501; m_Errno = 501;
asprintf(&m_Error, "Channel \"%s\" not defined", Option); m_Error = cString::sprintf("Channel \"%s\" not defined", Option);
return; return;
} }
} }
@ -410,24 +406,22 @@ cLSTCHandler::cLSTCHandler(cConnectionVTP *Client, const char *Option):
m_Traverse = true; m_Traverse = true;
} else { } else {
m_Errno = 550; m_Errno = 550;
m_Error = strdup("No channels defined"); m_Error = "No channels defined";
} }
} }
cLSTCHandler::~cLSTCHandler() cLSTCHandler::~cLSTCHandler()
{ {
Channels.Unlock(); Channels.Unlock();
if (m_Error != NULL)
free(m_Error);
if (m_Option != NULL) if (m_Option != NULL)
free(m_Option); free(m_Option);
} }
bool cLSTCHandler::Next(bool &Last) bool cLSTCHandler::Next(bool &Last)
{ {
if (m_Error != NULL) { if (*m_Error != NULL) {
Last = true; Last = true;
cString str(m_Error, true); cString str(m_Error);
m_Error = NULL; m_Error = NULL;
return m_Client->Respond(m_Errno, "%s", *str); return m_Client->Respond(m_Errno, "%s", *str);
} }
@ -452,7 +446,7 @@ bool cLSTCHandler::Next(bool &Last)
i = m_Channel->Number() + 1; i = m_Channel->Number() + 1;
} else { } else {
m_Errno = 501; m_Errno = 501;
asprintf(&m_Error, "Channel \"%d\" not found", i); m_Error = cString::sprintf("Channel \"%d\" not found", i);
} }
} }
@ -472,7 +466,7 @@ private:
cTimer *m_Timer; cTimer *m_Timer;
int m_Index; int m_Index;
int m_Errno; int m_Errno;
char *m_Error; cString m_Error;
bool m_Traverse; bool m_Traverse;
public: public:
cLSTTHandler(cConnectionVTP *Client, const char *Option); cLSTTHandler(cConnectionVTP *Client, const char *Option);
@ -485,7 +479,6 @@ cLSTTHandler::cLSTTHandler(cConnectionVTP *Client, const char *Option):
m_Timer(NULL), m_Timer(NULL),
m_Index(0), m_Index(0),
m_Errno(0), m_Errno(0),
m_Error(NULL),
m_Traverse(false) m_Traverse(false)
{ {
if (*Option) { if (*Option) {
@ -493,11 +486,11 @@ cLSTTHandler::cLSTTHandler(cConnectionVTP *Client, const char *Option):
m_Timer = Timers.Get(strtol(Option, NULL, 10) - 1); m_Timer = Timers.Get(strtol(Option, NULL, 10) - 1);
if (m_Timer == NULL) { if (m_Timer == NULL) {
m_Errno = 501; m_Errno = 501;
asprintf(&m_Error, "Timer \"%s\" not defined", Option); m_Error = cString::sprintf("Timer \"%s\" not defined", Option);
} }
} else { } else {
m_Errno = 501; m_Errno = 501;
asprintf(&m_Error, "Error in timer number \"%s\"", Option); m_Error = cString::sprintf("Error in timer number \"%s\"", Option);
} }
} else if (Timers.Count()) { } else if (Timers.Count()) {
m_Traverse = true; m_Traverse = true;
@ -505,25 +498,23 @@ cLSTTHandler::cLSTTHandler(cConnectionVTP *Client, const char *Option):
m_Timer = Timers.Get(m_Index); m_Timer = Timers.Get(m_Index);
if (m_Timer == NULL) { if (m_Timer == NULL) {
m_Errno = 501; m_Errno = 501;
asprintf(&m_Error, "Timer \"%d\" not found", m_Index + 1); m_Error = cString::sprintf("Timer \"%d\" not found", m_Index + 1);
} }
} else { } else {
m_Errno = 550; m_Errno = 550;
m_Error = strdup("No timers defined"); m_Error = "No timers defined";
} }
} }
cLSTTHandler::~cLSTTHandler() cLSTTHandler::~cLSTTHandler()
{ {
if (m_Error != NULL)
free(m_Error);
} }
bool cLSTTHandler::Next(bool &Last) bool cLSTTHandler::Next(bool &Last)
{ {
if (m_Error != NULL) { if (*m_Error != NULL) {
Last = true; Last = true;
cString str(m_Error, true); cString str(m_Error);
m_Error = NULL; m_Error = NULL;
return m_Client->Respond(m_Errno, "%s", *str); return m_Client->Respond(m_Errno, "%s", *str);
} }
@ -541,7 +532,7 @@ bool cLSTTHandler::Next(bool &Last)
m_Timer = Timers.Get(++m_Index); m_Timer = Timers.Get(++m_Index);
if (m_Timer == NULL) { if (m_Timer == NULL) {
m_Errno = 501; m_Errno = 501;
asprintf(&m_Error, "Timer \"%d\" not found", m_Index + 1); m_Error = cString::sprintf("Timer \"%d\" not found", m_Index + 1);
} }
} }
return result; return result;
@ -559,7 +550,7 @@ private:
const cEvent *m_Event; const cEvent *m_Event;
int m_Index; int m_Index;
int m_Errno; int m_Errno;
char *m_Error; cString m_Error;
bool m_Traverse; bool m_Traverse;
bool m_Info; bool m_Info;
eStates m_State; eStates m_State;
@ -576,7 +567,6 @@ cLSTRHandler::cLSTRHandler(cConnectionVTP *Client, const char *Option):
m_Event(NULL), m_Event(NULL),
m_Index(0), m_Index(0),
m_Errno(0), m_Errno(0),
m_Error(NULL),
m_Traverse(false), m_Traverse(false),
m_Info(false), m_Info(false),
m_State(Recording), m_State(Recording),
@ -591,12 +581,12 @@ cLSTRHandler::cLSTRHandler(cConnectionVTP *Client, const char *Option):
m_Info = true; m_Info = true;
if (m_Recording == NULL) { if (m_Recording == NULL) {
m_Errno = 501; m_Errno = 501;
asprintf(&m_Error, "Recording \"%s\" not found", Option); m_Error = cString::sprintf("Recording \"%s\" not found", Option);
} }
} }
else { else {
m_Errno = 501; m_Errno = 501;
asprintf(&m_Error, "Error in Recording number \"%s\"", Option); m_Error = cString::sprintf("Error in Recording number \"%s\"", Option);
} }
} }
else if (Recordings.Count()) { else if (Recordings.Count()) {
@ -605,26 +595,24 @@ cLSTRHandler::cLSTRHandler(cConnectionVTP *Client, const char *Option):
m_Recording = Recordings.Get(m_Index); m_Recording = Recordings.Get(m_Index);
if (m_Recording == NULL) { if (m_Recording == NULL) {
m_Errno = 501; m_Errno = 501;
asprintf(&m_Error, "Recording \"%d\" not found", m_Index + 1); m_Error = cString::sprintf("Recording \"%d\" not found", m_Index + 1);
} }
} }
else { else {
m_Errno = 550; m_Errno = 550;
m_Error = strdup("No recordings available"); m_Error = "No recordings available";
} }
} }
cLSTRHandler::~cLSTRHandler() cLSTRHandler::~cLSTRHandler()
{ {
if (m_Error != NULL)
free(m_Error);
} }
bool cLSTRHandler::Next(bool &Last) bool cLSTRHandler::Next(bool &Last)
{ {
if (m_Error != NULL) { if (*m_Error != NULL) {
Last = true; Last = true;
cString str(m_Error, true); cString str(m_Error);
m_Error = NULL; m_Error = NULL;
return m_Client->Respond(m_Errno, "%s", *str); return m_Client->Respond(m_Errno, "%s", *str);
} }
@ -714,7 +702,7 @@ bool cLSTRHandler::Next(bool &Last)
m_Recording = Recordings.Get(++m_Index); m_Recording = Recordings.Get(++m_Index);
if (m_Recording == NULL) { if (m_Recording == NULL) {
m_Errno = 501; m_Errno = 501;
asprintf(&m_Error, "Recording \"%d\" not found", m_Index + 1); m_Error = cString::sprintf("Recording \"%d\" not found", m_Index + 1);
} }
} }
return result; return result;
@ -1705,12 +1693,17 @@ bool cConnectionVTP::CmdRENR(const char *Option)
bool cConnectionVTP::Respond(int Code, const char *Message, ...) bool cConnectionVTP::Respond(int Code, const char *Message, ...)
{ {
char *buffer;
va_list ap; va_list ap;
va_start(ap, Message); va_start(ap, Message);
vasprintf(&buffer, Message, ap); #if APIVERSNUM < 10515
va_end(ap); char *buffer;
if (vasprintf(&buffer, Message, ap) < 0)
buffer = strdup("???");
cString str(buffer, true); cString str(buffer, true);
#else
cString str = cString::sprintf(Message, ap);
#endif
va_end(ap);
if (Code >= 0 && m_LastCommand != NULL) { if (Code >= 0 && m_LastCommand != NULL) {
free(m_LastCommand); free(m_LastCommand);
@ -1718,6 +1711,6 @@ bool cConnectionVTP::Respond(int Code, const char *Message, ...)
} }
return cServerConnection::Respond("%03d%c%s", Code >= 0, return cServerConnection::Respond("%03d%c%s", Code >= 0,
Code < 0 ? -Code : Code, Code < 0 ? -Code : Code,
Code < 0 ? '-' : ' ', buffer); Code < 0 ? '-' : ' ', *str);
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: setup.c,v 1.8 2009/09/18 10:50:44 schmirl Exp $ * $Id: setup.c,v 1.9 2009/10/13 06:38:47 schmirl Exp $
*/ */
#include <vdr/menuitems.h> #include <vdr/menuitems.h>
@ -94,13 +94,11 @@ cStreamdevServerMenuSetupPage::~cStreamdevServerMenuSetupPage() {
} }
void cStreamdevServerMenuSetupPage::AddCategory(const char *Title) { void cStreamdevServerMenuSetupPage::AddCategory(const char *Title) {
char *buffer = NULL;
asprintf(&buffer, "--- %s -------------------------------------------------" cString str = cString::sprintf("--- %s -------------------------------------------------"
"---------------", Title ); "---------------", Title );
cOsdItem *item = new cOsdItem(buffer); cOsdItem *item = new cOsdItem(*str);
free(buffer);
item->SetSelectable(false); item->SetSelectable(false);
Add(item); Add(item);
} }