1 /* ISC license. */
2
3 #include <sys/types.h>
4 #include <skalibs/functypes.h>
5 #include <skalibs/unix-timed.h>
6 #include <skalibs/unixmessage.h>
7
8 typedef struct unixmessage_get_s unixmessage_get_t, *unixmessage_get_t_ref ;
9 struct unixmessage_get_s
10 {
11 unixmessage_receiver_t *b ;
12 unixmessage_t *m ;
13 } ;
14
getfd(unixmessage_get_t * g)15 static int getfd (unixmessage_get_t *g)
16 {
17 return unixmessage_receiver_fd(g->b) ;
18 }
19
get(unixmessage_get_t * g)20 static ssize_t get (unixmessage_get_t *g)
21 {
22 return unixmessage_receive(g->b, g->m) ;
23 }
24
unixmessage_timed_receive(unixmessage_receiver_t * b,unixmessage_t * m,tain_t const * deadline,tain_t * stamp)25 int unixmessage_timed_receive (unixmessage_receiver_t *b, unixmessage_t *m, tain_t const *deadline, tain_t *stamp)
26 {
27 unixmessage_get_t g = { .b = b, .m = m } ;
28 return timed_get(&g, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ;
29 }
30