diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-12-22 16:07:12 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-12-22 16:07:12 +0000 |
commit | 275183baefa08dc91f094c1e59bd43a77684662d (patch) | |
tree | 2aeeb04d0c650afd05ad42de8f4f1f708527aa2e /src/skadns/skadns_update.c | |
parent | 6f2f670455a24032face2d8ee4684d051ae0e907 (diff) | |
download | s6-dns-275183baefa08dc91f094c1e59bd43a77684662d.tar.xz |
Port skadns to textclient, prepare for 2.3.0.0
Diffstat (limited to 'src/skadns/skadns_update.c')
-rw-r--r-- | src/skadns/skadns_update.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/skadns/skadns_update.c b/src/skadns/skadns_update.c index 39b1dd0..e26ead0 100644 --- a/src/skadns/skadns_update.c +++ b/src/skadns/skadns_update.c @@ -5,6 +5,7 @@ #define _BSD_SOURCE #endif +#include <sys/uio.h> #include <string.h> #include <stdint.h> #include <errno.h> @@ -13,17 +14,17 @@ #include <skalibs/alloc.h> #include <skalibs/genalloc.h> #include <skalibs/gensetdyn.h> -#include <skalibs/unixmessage.h> -#include <skalibs/skaclient.h> +#include <skalibs/textclient.h> #include <s6-dns/skadns.h> -static int msghandler (unixmessage_t const *m, void *context) +static int msghandler (struct iovec const *v, void *context) { skadns_t *a = (skadns_t *)context ; + char const *s = v->iov_base ; skadnsanswer_t *p ; uint16_t id ; - if (m->len < 3 || m->nfds) return (errno = EPROTO, 0) ; - uint16_unpack_big(m->s, &id) ; + if (v->iov_len < 3) return (errno = EPROTO, 0) ; + uint16_unpack_big(s, &id) ; p = GENSETDYN_P(skadnsanswer_t, &a->q, id) ; if (p->status == ECANCELED) { @@ -32,14 +33,14 @@ static int msghandler (unixmessage_t const *m, void *context) } if (!error_isagain(p->status)) return (errno = EINVAL, 0) ; if (!genalloc_readyplus(uint16_t, &a->list, 1)) return 0 ; - if (!m->s[2]) + if (!s[2]) { - p->data = alloc(m->len-3) ; + p->data = alloc(v->iov_len-3) ; if (!p->data) return 0 ; - memcpy(p->data, m->s+3, m->len-3) ; - p->len = m->len-3 ; + memcpy(p->data, s+3, v->iov_len-3) ; + p->len = v->iov_len-3 ; } - p->status = m->s[2] ; + p->status = s[2] ; genalloc_append(uint16_t, &a->list, &id) ; return 1 ; } @@ -47,5 +48,5 @@ static int msghandler (unixmessage_t const *m, void *context) int skadns_update (skadns_t *a) { genalloc_setlen(uint16_t, &a->list, 0) ; - return skaclient_update(&a->connection, &msghandler, a) ; + return textclient_update(&a->connection, &msghandler, a) ; } |