diff options
author | Mikhail Burakov <mburakov@mailbox.org> | 2024-05-12 15:05:50 +0200 |
---|---|---|
committer | Mikhail Burakov <mburakov@mailbox.org> | 2024-05-12 15:05:50 +0200 |
commit | d511fae02fba6f6c8ea2896d5a6cefd8d3337ca3 (patch) | |
tree | 966f39c3fe988c96f75e5220cd10e4a8b6fdf0e5 /input.c | |
parent | 918682faa29197fe3b0a544906638e02785a6b17 (diff) |
Add generic proto writing method
Diffstat (limited to 'input.c')
-rw-r--r-- | input.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -100,12 +100,11 @@ bool InputHandlerHandle(struct InputHandler* input_handler, int fd) { // mburakov: Payload of ping message is not yet available. return true; } - char buffer[sizeof(struct Proto) + sizeof(uint64_t)]; - struct Proto* proto = (void*)buffer; - proto->size = sizeof(uint64_t); - proto->type = PROTO_TYPE_MISC; - memcpy(proto->data, &event->u, sizeof(uint64_t)); - if (write(fd, buffer, sizeof(buffer)) != sizeof(buffer)) { + struct Proto proto = { + .size = sizeof(uint64_t), + .type = PROTO_TYPE_MISC, + }; + if (!WriteProto(fd, &proto, &event->u)) { LOG("Failed to write pong message (%s)", strerror(errno)); return false; } |