silenced warnings concerning asprintf (requested by Rolf Ahrenberg)

Modified Files:
 Tag: v0_4
	CONTRIBUTORS HISTORY server/connectionVTP.c server/setup.c
This commit is contained in:
schmirl 2009-10-13 06:38:58 +00:00
parent 900af77de7
commit 824a192579
4 changed files with 51 additions and 62 deletions

View File

@ -34,6 +34,7 @@ Rolf Ahrenberg
for improving externremux script termination
for fixing PAT repacker version field
for suggesting to include the charset in HTTP replies
for requesting replacement of asprintf calls
Rantanen Teemu
for providing vdr-incompletesections.diff

View File

@ -1,6 +1,7 @@
VDR Plugin 'streamdev' Revision History
---------------------------------------
- silenced warnings concerning asprintf (requested by Rolf Ahrenberg)
- don't update recordings list on CmdPLAY (reported by BBlack)
- adapted and included xmbc patch for VDR 1.4.x
- cleaned up common.h / common.c

View File

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

View File

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