Write header to stdout target.

This commit is contained in:
Ian Gulliver
2016-02-27 21:56:37 -08:00
parent 92334724f0
commit 4f0b2c82e9

View File

@@ -2,6 +2,7 @@
#include <string.h>
#include <unistd.h>
#include "buf.h"
#include "incoming.h"
#include "outgoing.h"
#include "peer.h"
@@ -97,6 +98,17 @@ bool opts_add_stdout(char *arg) {
if (!serializer) {
return false;
}
send_new(dup(1), serializer, NULL);
int fd = dup(1);
{
// TODO: move into standard location for non-socket fd handling
struct buf buf = BUF_INIT, *buf_ptr = &buf;
send_hello(&buf_ptr, serializer);
if (buf_ptr->length) {
if (write(fd, buf_at(buf_ptr, 0), buf_ptr->length) != (ssize_t) buf_ptr->length) {
return false;
}
}
}
send_new(fd, serializer, NULL);
return true;
}