From e2959c22c7309836d6f5dba2f0db7b293b860ad8 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sun, 28 Mar 2021 01:50:36 +0000 Subject: A few pieces of the future s6-rcd server --- src/server/command.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/server/command.c (limited to 'src/server/command.c') diff --git a/src/server/command.c b/src/server/command.c new file mode 100644 index 0000000..c52dc8b --- /dev/null +++ b/src/server/command.c @@ -0,0 +1,43 @@ +/* ISC license. */ + +#include +#include + +#include +#include + +#include "client.h" +#include "command.h" + +static int answer (client_t *c, char e) +{ + if (!textmessage_put(&c->connection.out, &e, 1)) return 0 ; + client_setdeadline(c) ; + return 1 ; +} + +static int do_query (client_t *c, char const *s, size_t len) +{ + if (!len--) return (errno = EPROTO, 0) ; +} + +static int do_monitor (client_t *c, char const *s, size_t len) +{ +} + +int command_handle (struct iovec const *v, void *aux) +{ + client_t *c = aux ; + char const *s = v->iov_base ; + size_t len = v->iov_len ; + if (!len--) return (errno = EPROTO, 0) ; + switch (*s++) + { + case 'Q' : return do_query(c, s, len) ; + case 'M' : return do_monitor(c, s, len) ; + case '?' : return do_change(c, s, len) ; + case '!' : return do_event(c, s, len) ; + case '#' : return do_admin(c, s, len) ; + default : return do_error(c) ; + } +} -- cgit v1.2.3