summaryrefslogtreecommitdiff
path: root/svdrp.c
diff options
context:
space:
mode:
Diffstat (limited to 'svdrp.c')
-rw-r--r--svdrp.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/svdrp.c b/svdrp.c
index 2ac3a4b..4317535 100644
--- a/svdrp.c
+++ b/svdrp.c
@@ -10,7 +10,7 @@
* and interact with the Video Disk Recorder - or write a full featured
* graphical interface that sits on top of an SVDRP connection.
*
- * $Id: svdrp.c 1.105 2008/01/13 15:06:25 kls Exp $
+ * $Id: svdrp.c 1.109 2008/02/17 13:36:01 kls Exp $
*/
#include "svdrp.h"
@@ -421,8 +421,8 @@ void cSVDRP::Reply(int Code, const char *fmt, ...)
if (Code != 0) {
va_list ap;
va_start(ap, fmt);
- char *buffer;
- vasprintf(&buffer, fmt, ap);
+ cString buffer = cString::sprintf(fmt, ap);
+ va_end(ap);
const char *s = buffer;
while (s && *s) {
const char *n = strchr(s, '\n');
@@ -435,8 +435,6 @@ void cSVDRP::Reply(int Code, const char *fmt, ...)
break;
s = n ? n + 1 : NULL;
}
- free(buffer);
- va_end(ap);
}
else {
Reply(451, "Zero return code - looks like a programming error!");
@@ -728,7 +726,7 @@ void cSVDRP::CmdEDIT(const char *Option)
void cSVDRP::CmdGRAB(const char *Option)
{
- char *FileName = NULL;
+ const char *FileName = NULL;
bool Jpeg = true;
int Quality = -1, SizeX = -1, SizeY = -1;
if (*Option) {
@@ -797,10 +795,10 @@ void cSVDRP::CmdGRAB(const char *Option)
char RealFileName[PATH_MAX];
if (FileName) {
if (grabImageDir) {
- char *s = 0;
+ cString s;
char *slash = strrchr(FileName, '/');
if (!slash) {
- asprintf(&s, "%s/%s", grabImageDir, FileName);
+ s = AddDirectory(grabImageDir, FileName);
FileName = s;
}
slash = strrchr(FileName, '/'); // there definitely is one
@@ -810,12 +808,10 @@ void cSVDRP::CmdGRAB(const char *Option)
if (!r) {
LOG_ERROR_STR(FileName);
Reply(501, "Invalid file name \"%s\"", FileName);
- free(s);
return;
}
strcat(RealFileName, slash);
FileName = RealFileName;
- free(s);
if (strncmp(FileName, grabImageDir, strlen(grabImageDir)) != 0) {
Reply(501, "Invalid file name \"%s\"", FileName);
return;
@@ -1424,7 +1420,7 @@ void cSVDRP::CmdPLUG(const char *Option)
else {
int ReplyCode = 900;
cString s = plugin->SVDRPCommand(cmd, option, ReplyCode);
- if (s)
+ if (*s)
Reply(abs(ReplyCode), "%s", *s);
else
Reply(500, "Command unrecognized: \"%s\"", cmd);