Convenience function for simple hello.
This commit is contained in:
@@ -98,17 +98,5 @@ bool opts_add_stdout(char *arg) {
|
|||||||
if (!serializer) {
|
if (!serializer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int fd = dup(1);
|
return send_new_hello(dup(1), serializer, NULL);
|
||||||
{
|
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,6 +136,18 @@ void send_new_wrapper(int fd, void *passthrough, struct peer *on_close) {
|
|||||||
send_new(fd, (struct serializer *) passthrough, on_close);
|
send_new(fd, (struct serializer *) passthrough, on_close);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool send_new_hello(int fd, struct serializer *serializer, struct peer *on_close) {
|
||||||
|
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, on_close);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void send_hello(struct buf **buf_pp, void *passthrough) {
|
void send_hello(struct buf **buf_pp, void *passthrough) {
|
||||||
struct serializer *serializer = (struct serializer *) passthrough;
|
struct serializer *serializer = (struct serializer *) passthrough;
|
||||||
if (serializer->hello) {
|
if (serializer->hello) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ void send_cleanup(void);
|
|||||||
struct serializer *send_get_serializer(char *);
|
struct serializer *send_get_serializer(char *);
|
||||||
void send_new(int, struct serializer *, struct peer *);
|
void send_new(int, struct serializer *, struct peer *);
|
||||||
void send_new_wrapper(int, void *, struct peer *);
|
void send_new_wrapper(int, void *, struct peer *);
|
||||||
|
bool send_new_hello(int, struct serializer *, struct peer *);
|
||||||
void send_hello(struct buf **, void *);
|
void send_hello(struct buf **, void *);
|
||||||
void send_write(struct packet *);
|
void send_write(struct packet *);
|
||||||
void send_print_usage(void);
|
void send_print_usage(void);
|
||||||
|
|||||||
Reference in New Issue
Block a user