- buffer_t buf;
-
- buffer_init(&buf);
- for (;;) {
- ssize_t search_offs = MAX(0, buf.len - 1);
- int nb = buffer_read(&buf, fd, -1);
- const char *eoq;
- query_t q;
-
- if (nb < 0) {
- if (errno == EAGAIN || errno == EINTR)
- continue;
- UNIXERR("read");
- break;
- }
- if (nb == 0) {
- if (buf.len)
- syslog(LOG_ERR, "unexpected end of data");
- break;
- }
-
- eoq = strstr(buf.data + search_offs, "\n\n");
- if (!eoq)
- continue;
+ va_list args;
+ va_start(args, fmt);
+ buffer_addvf(&pcy->obuf, fmt, args);
+ va_end(args);
+ buffer_addstr(&pcy->obuf, "\n\n");
+ buffer_consume(&pcy->ibuf, pcy->q.eoq - pcy->ibuf.data);
+ epoll_modify(pcy->fd, EPOLLIN | EPOLLOUT, pcy);
+}