summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8e2f27a)
raw | patch | inline | side by side (parent: 8e2f27a)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 23 Feb 2008 18:25:03 +0000 (19:25 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 23 Feb 2008 18:25:03 +0000 (19:25 +0100) |
src/utils_tail.c | patch | blob | history |
diff --git a/src/utils_tail.c b/src/utils_tail.c
index b73c1f99058bf5bd3544176d8bfecfd187b2f780..58e027e4f2ff565fa81a2dc549cb94e6e01c4ddd 100644 (file)
--- a/src/utils_tail.c
+++ b/src/utils_tail.c
int status;
if (buflen < 1)
+ {
+ ERROR ("utils_tail: cu_tail_readline: buflen too small: "
+ "%i bytes.", buflen);
return (-1);
+ }
if (stat (obj->file, &stat_now) != 0)
{
*/
FILE *new_fd;
+ DEBUG ("utils_tail: cu_tail_readline: (Re)Opening %s..",
+ obj->file);
+
new_fd = fopen (obj->file, "r");
if (new_fd == NULL)
{
char errbuf[1024];
- ERROR ("cu_tail_readline: open (%s) failed: %s",
+ ERROR ("utils_tail: cu_tail_readline: open (%s) failed: %s",
obj->file,
sstrerror (errno, errbuf,
sizeof (errbuf)));
status = 0;
if (fgets (buf, buflen, obj->fd) == NULL)
{
- if (feof (obj->fd) == 0)
+ if (feof (obj->fd) != 0)
buf[0] = '\0';
else /* an error occurred */
+ {
+ ERROR ("utils_tail: cu_tail_readline: fgets returned "
+ "an error.");
status = -1;
+ }
}
if (status == 0)
@@ -142,15 +153,27 @@ int cu_tail_read (cu_tail_t *obj, char *buf, int buflen, tailfunc_t *callback,
{
int status;
- while ((status = cu_tail_readline (obj, buf, buflen)) == 0)
+ while (42)
{
+ status = cu_tail_readline (obj, buf, buflen);
+ if (status != 0)
+ {
+ ERROR ("utils_tail: cu_tail_read: cu_tail_readline "
+ "failed.");
+ break;
+ }
+
/* check for EOF */
if (buf[0] == '\0')
break;
status = callback (data, buf, buflen);
if (status != 0)
+ {
+ ERROR ("utils_tail: cu_tail_read: callback returned "
+ "status %i.", status);
break;
+ }
}
return status;