106 lines
2.9 KiB
Diff
106 lines
2.9 KiB
Diff
From 90414320c7d3fbfa64642d8039bead632b2bed1e Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= <mat@brain-dump.org>
|
|
Date: Wed, 21 Jun 2017 22:37:43 +0200
|
|
Subject: [PATCH 1/4] Use fixed size integer types in protocol messages
|
|
|
|
This should make it possible to connect with a 32bit client to a 64bit
|
|
server. This might also make it possible to forward the abduco socket
|
|
over SSH as described in #25. Different endianness are not supported at
|
|
this time.
|
|
|
|
This is a breaking protocol change. Make sure to use the same version
|
|
as client and server (anything else is unsupported anyway!).
|
|
---
|
|
abduco.c | 12 ++++++++----
|
|
client.c | 2 +-
|
|
debug.c | 4 ++--
|
|
server.c | 5 ++++-
|
|
4 files changed, 15 insertions(+), 8 deletions(-)
|
|
|
|
diff --git abduco.c abduco.c
|
|
index 3c60a36..1bd6304 100644
|
|
--- a/abduco.c
|
|
+++ b/abduco.c
|
|
@@ -15,6 +15,7 @@
|
|
*/
|
|
#include <errno.h>
|
|
#include <fcntl.h>
|
|
+#include <inttypes.h>
|
|
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
#include <stdlib.h>
|
|
@@ -71,12 +72,15 @@ enum PacketType {
|
|
};
|
|
|
|
typedef struct {
|
|
- unsigned int type;
|
|
- size_t len;
|
|
+ uint32_t type;
|
|
+ uint32_t len;
|
|
union {
|
|
char msg[BUFSIZ];
|
|
- struct winsize ws;
|
|
- int i;
|
|
+ struct {
|
|
+ uint16_t rows;
|
|
+ uint16_t cols;
|
|
+ } ws;
|
|
+ uint32_t i;
|
|
} u;
|
|
} Packet;
|
|
|
|
diff --git client.c client.c
|
|
index 744f061..2c2192b 100644
|
|
--- a/client.c
|
|
+++ b/client.c
|
|
@@ -78,7 +78,7 @@ static int client_mainloop(void) {
|
|
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) != -1) {
|
|
Packet pkt = {
|
|
.type = MSG_RESIZE,
|
|
- .u = { .ws = ws },
|
|
+ .u = { .ws = { .rows = ws.ws_row, .cols = ws.ws_col } },
|
|
.len = sizeof(ws),
|
|
};
|
|
if (client_send_packet(&pkt))
|
|
diff --git debug.c debug.c
|
|
index b5748ab..e904e33 100644
|
|
--- a/debug.c
|
|
+++ b/debug.c
|
|
@@ -29,7 +29,7 @@ static void print_packet(const char *prefix, Packet *pkt) {
|
|
fwrite(pkt->u.msg, pkt->len, 1, stderr);
|
|
break;
|
|
case MSG_RESIZE:
|
|
- fprintf(stderr, "%dx%d", pkt->u.ws.ws_col, pkt->u.ws.ws_row);
|
|
+ fprintf(stderr, "%"PRIu16"x%"PRIu16, pkt->u.ws.cols, pkt->u.ws.rows);
|
|
break;
|
|
case MSG_ATTACH:
|
|
fprintf(stderr, "readonly: %d low-priority: %d",
|
|
@@ -37,7 +37,7 @@ static void print_packet(const char *prefix, Packet *pkt) {
|
|
pkt->u.i & CLIENT_LOWPRIORITY);
|
|
break;
|
|
default:
|
|
- fprintf(stderr, "len: %zu", pkt->len);
|
|
+ fprintf(stderr, "len: %"PRIu32, pkt->len);
|
|
break;
|
|
}
|
|
fprintf(stderr, "\n");
|
|
diff --git server.c server.c
|
|
index 78ccbe2..6f62cfb 100644
|
|
--- a/server.c
|
|
+++ b/server.c
|
|
@@ -224,7 +224,10 @@ static void server_mainloop(void) {
|
|
case MSG_REDRAW:
|
|
if (!(c->flags & CLIENT_READONLY) && (client_packet.type == MSG_REDRAW || c == server.clients)) {
|
|
debug("server-ioct: TIOCSWINSZ\n");
|
|
- ioctl(server.pty, TIOCSWINSZ, &client_packet.u.ws);
|
|
+ struct winsize ws = { 0 };
|
|
+ ws.ws_row = client_packet.u.ws.rows;
|
|
+ ws.ws_col = client_packet.u.ws.cols;
|
|
+ ioctl(server.pty, TIOCSWINSZ, &ws);
|
|
}
|
|
kill(-server.pid, SIGWINCH);
|
|
break;
|
|
--
|
|
2.24.0
|
|
|