From 90b12bd71bb9fc79a4640b9112c13ef529d0196a Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 5 Dec 2014 22:26:11 +0000 Subject: Initial commit --- src/libs6/ftrigr_update.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/libs6/ftrigr_update.c (limited to 'src/libs6/ftrigr_update.c') diff --git a/src/libs6/ftrigr_update.c b/src/libs6/ftrigr_update.c new file mode 100644 index 0000000..ad69714 --- /dev/null +++ b/src/libs6/ftrigr_update.c @@ -0,0 +1,43 @@ +/* ISC license. */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static int msghandler (unixmessage_t const *m, void *context) +{ + ftrigr_t *a = (ftrigr_t *)context ; + ftrigr1_t *p ; + uint16 id ; + if (m->len != 4 || m->nfds) return (errno = EPROTO, 0) ; + uint16_unpack_big(m->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, &a->list, 1)) return 0 ; + switch (m->s[2]) + { + case 'd' : + p->state = FR1STATE_WAITACK ; + break ; + case '!' : + if (p->options & FTRIGR_REPEAT) p->count++ ; + else p->state = FR1STATE_WAITACKDATA ; + break ; + default : return (errno = EPROTO, 0) ; + } + p->what = m->s[3] ; + id++ ; genalloc_append(uint16, &a->list, &id) ; + return 1 ; +} + +int ftrigr_update (ftrigr_t *a) +{ + genalloc_setlen(uint16, &a->list, 0) ; + return skaclient_update(&a->connection, &msghandler, a) ; +} -- cgit v1.3.1