#include <time.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include "err_util.h"
void qword_add(char **bpp, int *lp, char *str)
}
len = read(fd, *buf, *lenp);
if (len <= 0) {
- printerr(2, "read error in readline: %d\n", len);
+ printerr(0, "readline: read error: len %d errno %d (%s)\n",
+ len, errno, strerror(errno));
return 0;
}
while ((*buf)[len-1] != '\n') {
*buf = new;
nl = read(fd, *buf +len, *lenp - len);
if (nl <= 0 ) {
- printerr(2, "read error in readline: %d\n", nl);
+ printerr(0, "readline: read error: len %d "
+ "errno %d (%s)\n", nl, errno, strerror(errno));
return 0;
}
len += nl;
}
(*buf)[len-1] = 0;
- printerr(1, "read line with %d characters:\n%s\n", *lenp, *buf);
+ printerr(3, "readline: read %d chars into buffer of size %d:\n%s\n",
+ len, *lenp, *buf);
return 1;
}
return -1;
}
*bp = '\0';
- printerr(1, "writing message: %s", buf);
+ printerr(3, "writing message: %s", buf);
if (write(g, buf, bp - buf) == -1) {
printerr(0, "WARNING: failed to write message\n");
close(g);