void filter_api_writeln(uint64_t id, const char *line) { struct filter_session *s; log_trace(TRACE_FILTERS, "filter-api:%s %016"PRIx64" filter_api_writeln(%s)", filter_name, id, line); s = tree_xget(&sessions, id); if (s->pipe.oev.sock == -1) { log_warnx("warn: filter:%s: cannot write at this point", filter_name); fatalx("exiting"); } s->pipe.odatalen += strlen(line) + 1; iobuf_fqueue(&s->pipe.obuf, "%s\n", line); io_reload(&s->pipe.oev); }
static int clamav_write(struct clamav *cl, const char *l, int f) { size_t len = (f == EOF) ? 0 : strlen(l) + 1; uint32_t n = htonl(len); if (f && iobuf_queue(&cl->iobuf, &n, sizeof(uint32_t)) != (int)sizeof(uint32_t)) { log_warn("warn: write: iobuf_queue"); return -1; } if (f != EOF && iobuf_fqueue(&cl->iobuf, "%s\n", l) != (int)len) { log_warn("warn: write: iobuf_fqueue"); return -1; } if (iobuf_flush(&cl->iobuf, cl->fd) < 0) { log_warn("warn: write: iobuf_flush"); return -1; } return 0; }