abduco

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit 577ae6ae7a925d00836b333675522fba3c45fad0
parent 75dc9a52fad658e770de043ae1b906737985453b
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sun,  3 Jan 2016 12:03:02 +0100

Slightly tweek communication protocol for -l option

Diffstat:
abduco.c | 14+++++++-------
client.c | 6+++---
server.c | 6+++---
3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/abduco.c b/abduco.c @@ -77,9 +77,6 @@ typedef struct { char msg[BUFSIZ]; struct winsize ws; int i; - struct { - bool ro, lp; - } attach; } u; } Packet; @@ -93,7 +90,10 @@ struct Client { STATE_DISCONNECTED, } state; bool need_resize; - bool readonly; + enum { + CLIENT_READONLY = 1 << 0, + CLIENT_LOWPRIORITY = 1 << 1, + } flags; Client *next; }; @@ -116,7 +116,7 @@ typedef struct { static Server server = { .running = true, .exit_status = -1, .host = "@localhost" }; static Client client; static struct termios orig_term, cur_term; -static bool has_term, alternate_buffer, low_priority; +static bool has_term, alternate_buffer; static struct sockaddr_un sockaddr = { .sun_family = AF_UNIX, @@ -603,10 +603,10 @@ int main(int argc, char *argv[]) { force = true; break; case 'r': - client.readonly = true; + client.flags |= CLIENT_READONLY; break; case 'l': - low_priority = true; + client.flags |= CLIENT_LOWPRIORITY; break; case 'v': puts("abduco-"VERSION" © 2013-2015 Marc André Tanner"); diff --git a/client.c b/client.c @@ -62,8 +62,8 @@ static int client_mainloop(void) { client.need_resize = true; Packet pkt = { .type = MSG_ATTACH, - .u = { .attach = { .ro = client.readonly, .lp = low_priority } }, - .len = sizeof(pkt.u.attach), + .u.i = client.flags, + .len = sizeof(pkt.u.i), }; client_send_packet(&pkt); @@ -126,7 +126,7 @@ static int client_mainloop(void) { client_send_packet(&pkt); close(server.socket); return -1; - } else if (!client.readonly) { + } else if (!(client.flags & CLIENT_READONLY)) { client_send_packet(&pkt); } } diff --git a/server.c b/server.c @@ -213,14 +213,14 @@ static void server_mainloop(void) { server_write_pty(&client_packet); break; case MSG_ATTACH: - c->readonly = client_packet.u.attach.ro; - if (client_packet.u.attach.lp) + c->flags = client_packet.u.i; + if (c->flags & CLIENT_LOWPRIORITY) server_sink_client(); break; case MSG_RESIZE: c->state = STATE_ATTACHED; case MSG_REDRAW: - if (!c->readonly && (client_packet.type == MSG_REDRAW || c == server.clients)) { + 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); }