From d7242bda59ec2ec056508b39cb532b5e7318dd13 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 22 Dec 2017 17:37:09 +0000 Subject: Port ftrigr and s6lock to textclient --- src/libs6/ftrigr_updateb.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/libs6/ftrigr_updateb.c') diff --git a/src/libs6/ftrigr_updateb.c b/src/libs6/ftrigr_updateb.c index edf6f2c..5f0bd77 100644 --- a/src/libs6/ftrigr_updateb.c +++ b/src/libs6/ftrigr_updateb.c @@ -1,6 +1,7 @@ /* ISC license. */ #include +#include #include #include #include @@ -8,8 +9,7 @@ #include #include #include -#include -#include +#include #include static inline int appears (uint16_t, uint16_t const *, size_t) gccattr_pure ; @@ -20,26 +20,27 @@ static inline int appears (uint16_t id, uint16_t const *list, size_t len) return 0 ; } -static int msghandler (unixmessage_t const *m, void *context) +static int msghandler (struct iovec const *v, void *context) { ftrigr_t *a = (ftrigr_t *)context ; ftrigr1_t *p ; int addit = 1 ; + char const *s = v->iov_base ; uint16_t id ; - if (m->len != 4 || m->nfds) return (errno = EPROTO, 0) ; - uint16_unpack_big(m->s, &id) ; + if (v->iov_len != 4) return (errno = EPROTO, 0) ; + uint16_unpack_big(s, &id) ; p = GENSETDYN_P(ftrigr1_t, &a->data, id) ; if (!p) return 1 ; if (p->state != FR1STATE_LISTENING) return (errno = EINVAL, 0) ; if (!genalloc_readyplus(uint16_t, &a->list, 1)) return 0 ; - switch (m->s[2]) + switch (s[2]) { case 'd' : - if (!stralloc_catb(&p->what, m->s + 3, 1)) return 0 ; + if (!stralloc_catb(&p->what, s + 3, 1)) return 0 ; p->state = FR1STATE_WAITACK ; break ; case '!' : - if (!stralloc_catb(&p->what, m->s + 3, 1)) return 0 ; + if (!stralloc_catb(&p->what, s + 3, 1)) return 0 ; if (p->options & FTRIGR_REPEAT) { if (p->what.len > 1 @@ -60,6 +61,6 @@ static int msghandler (unixmessage_t const *m, void *context) int ftrigr_updateb (ftrigr_t *a) { size_t curlen = genalloc_len(uint16_t, &a->list) ; - int r = skaclient_update(&a->connection, &msghandler, a) ; + int r = textclient_update(&a->connection, &msghandler, a) ; return r < 0 ? r : (int)(genalloc_len(uint16_t, &a->list) - curlen) ; } -- cgit v1.3.1