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_check.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/libs6/ftrigr_check.c (limited to 'src/libs6/ftrigr_check.c') diff --git a/src/libs6/ftrigr_check.c b/src/libs6/ftrigr_check.c new file mode 100644 index 0000000..147deca --- /dev/null +++ b/src/libs6/ftrigr_check.c @@ -0,0 +1,40 @@ +/* ISC license. */ + +#include +#include +#include +#include + +int ftrigr_check (ftrigr_t *a, uint16 id, char *c) +{ + ftrigr1_t *p ; + if (!id--) return (errno = EINVAL, -1) ; + p = GENSETDYN_P(ftrigr1_t, &a->data, id) ; + if (!p) return (errno = EINVAL, -1) ; + switch (p->state) + { + case FR1STATE_WAITACKDATA : + { + *c = p->what ; + *p = ftrigr1_zero ; + gensetdyn_delete(&a->data, id) ; + return 1 ; + } + case FR1STATE_LISTENING : + { + register unsigned int r = p->count ; + if (r) *c = p->what ; + p->count = 0 ; + return (int)r ; + } + case FR1STATE_WAITACK : + { + errno = p->what ; + *p = ftrigr1_zero ; + gensetdyn_delete(&a->data, id) ; + return -1 ; + } + default: return (errno = EINVAL, -1) ; + } + return 0 ; +} -- cgit v1.2.3