summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dvbapi.c37
-rw-r--r--recording.c4
-rw-r--r--svdrp.c12
3 files changed, 21 insertions, 32 deletions
diff --git a/dvbapi.c b/dvbapi.c
index 9b96d31d..973ad54b 100644
--- a/dvbapi.c
+++ b/dvbapi.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: dvbapi.c 1.164 2002/03/23 14:14:03 kls Exp $
+ * $Id: dvbapi.c 1.165 2002/03/23 16:15:00 kls Exp $
*/
#include "dvbapi.h"
@@ -98,7 +98,7 @@ class cIndexFile {
private:
struct tIndex { int offset; uchar type; uchar number; short reserved; };
int f;
- char *fileName, *pFileExt;
+ char *fileName;
int size, last;
tIndex *index;
cResumeFile resumeFile;
@@ -120,7 +120,7 @@ cIndexFile::cIndexFile(const char *FileName, bool Record)
:resumeFile(FileName)
{
f = -1;
- fileName = pFileExt = NULL;
+ fileName = NULL;
size = 0;
last = -1;
index = NULL;
@@ -128,7 +128,7 @@ cIndexFile::cIndexFile(const char *FileName, bool Record)
fileName = new char[strlen(FileName) + strlen(INDEXFILESUFFIX) + 1];
if (fileName) {
strcpy(fileName, FileName);
- pFileExt = fileName + strlen(fileName);
+ char *pFileExt = fileName + strlen(fileName);
strcpy(pFileExt, INDEXFILESUFFIX);
int delta = 0;
if (access(fileName, R_OK) == 0) {
@@ -177,8 +177,6 @@ cIndexFile::cIndexFile(const char *FileName, bool Record)
}
else
LOG_ERROR_STR(fileName);
- delete fileName;
- fileName = pFileExt = NULL;
}
}
else
@@ -223,14 +221,14 @@ bool cIndexFile::CatchUp(int Index)
last = newLast;
}
else
- LOG_ERROR;
+ LOG_ERROR_STR(fileName);
}
else
esyslog(LOG_ERR, "ERROR: can't realloc() index");
}
}
else
- LOG_ERROR;
+ LOG_ERROR_STR(fileName);
if (Index >= last)
sleep(1);
else
@@ -244,8 +242,8 @@ bool cIndexFile::Write(uchar PictureType, uchar FileNumber, int FileOffset)
{
if (f >= 0) {
tIndex i = { FileOffset, PictureType, FileNumber, 0 };
- if (safe_write(f, &i, sizeof(i)) != sizeof(i)) {
- esyslog(LOG_ERR, "ERROR: can't write to index file");
+ if (safe_write(f, &i, sizeof(i)) < 0) {
+ LOG_ERROR_STR(fileName);
close(f);
f = -1;
return false;
@@ -579,17 +577,12 @@ void cRecordBuffer::Output(void)
if (NextFile()) {
if (index && pictureType != NO_PICTURE)
index->Write(pictureType, fileName.Number(), fileSize);
- while (Result > 0) {
- int w = safe_write(recordFile, p, Result);
- if (w < 0) {
- LOG_ERROR_STR(fileName.Name());
- recording = false;
- return;
- }
- p += w;
- Result -= w;
- fileSize += w;
- }
+ if (safe_write(recordFile, p, Result) < 0) {
+ LOG_ERROR_STR(fileName.Name());
+ recording = false;
+ return;
+ }
+ fileSize += Result;
}
else
break;
@@ -1557,7 +1550,7 @@ void cCuttingBuffer::Action(void)
}
LastIFrame = 0;
}
- if (safe_write(toFile, buffer, Length) != Length) {
+ if (safe_write(toFile, buffer, Length) < 0) {
error = "safe_write";
break;
}
diff --git a/recording.c b/recording.c
index 0121d6ce..bcbdfa65 100644
--- a/recording.c
+++ b/recording.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: recording.c 1.58 2002/03/23 11:32:33 kls Exp $
+ * $Id: recording.c 1.59 2002/03/23 16:15:32 kls Exp $
*/
#include "recording.h"
@@ -172,7 +172,7 @@ bool cResumeFile::Save(int Index)
if (fileName) {
int f = open(fileName, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (f >= 0) {
- if (safe_write(f, &Index, sizeof(Index)) != sizeof(Index))
+ if (safe_write(f, &Index, sizeof(Index)) < 0)
LOG_ERROR_STR(fileName);
close(f);
return true;
diff --git a/svdrp.c b/svdrp.c
index 06f8ebbc..751a5c54 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.34 2002/03/08 17:17:05 kls Exp $
+ * $Id: svdrp.c 1.35 2002/03/23 16:17:39 kls Exp $
*/
#include "svdrp.h"
@@ -340,16 +340,12 @@ bool cSVDRP::Send(const char *s, int length)
{
if (length < 0)
length = strlen(s);
- int wbytes = safe_write(file, s, length);
- if (wbytes == length)
- return true;
- if (wbytes < 0) {
+ if (safe_write(file, s, length) < 0) {
LOG_ERROR;
file.Close();
+ return false;
}
- else //XXX while...???
- esyslog(LOG_ERR, "Wrote %d bytes to client while expecting %d\n", wbytes, length);
- return false;
+ return true;
}
void cSVDRP::Reply(int Code, const char *fmt, ...)