summaryrefslogtreecommitdiff
path: root/src/libunixonacid/unixmessage_timed_receive.c
blob: 3761d26b41ac01f123ef6086ac75e5d8edb7d61d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* ISC license. */

#include <skalibs/functypes.h>
#include <skalibs/tai.h>
#include <skalibs/unix-timed.h>
#include <skalibs/unixmessage.h>

typedef struct unixmessage_get_s unixmessage_get_t, *unixmessage_get_t_ref ;
struct unixmessage_get_s
{
  unixmessage_receiver_t *b ;
  unixmessage_t *m ;
} ;

static int getfd (unixmessage_get_t *g)
{
  return unixmessage_receiver_fd(g->b) ;
}

static int get (unixmessage_get_t *g)
{
  return unixmessage_receive(g->b, g->m) ;
}

int unixmessage_timed_receive (unixmessage_receiver_t *b, unixmessage_t *m, tain_t const *deadline, tain_t *stamp)
{
  unixmessage_get_t g = { .b = b, .m = m } ;
  return timed_get(&g, (initfunc_t *)&getfd, (initfunc_t *)&get, deadline, stamp) ;
}