+fifo_read_error(Fifo *f, char *buf)
+{
+ char *b;
+ int i;
+
+ b = buf + f->pos;
+ /* Copy as much of the error message as possible.
+ * EXCLUDING the reminating \0. */
+ for (i = 0; i < errlen && i < f->width; i++)
+ b[i] = errmsg[i];
+ /* Any remaining slots: */
+ for (; i < f->width; i++)
+ b[i] = '_';
+}
+
+void
+fifo_read_one(Fifo *f, char *buf)
+{
+ ssize_t current;
+ ssize_t total;
+ char *b;
+ char c;
+
+ current = 0;
+ total = 0;
+ c = '\0';
+ b = buf + f->pos;
+ while ((current = read(f->fd, &c, 1)) && c != '\n' && c != '\0' && total++ < f->width)
+ *b++ = c;
+ if (current == -1) {
+ error("Failed to read: \"%s\". Error: %s\n", f->name, strerror(errno));
+ fifo_read_error(f, buf);
+ } else
+ while (total++ < f->width)
+ *b++ = ' ';
+ /* TODO Record timestamp read */
+ close(f->fd);
+ f->fd = -1;
+}
+
+void
+fifo_read_all(Config *cfg, char *buf)