summaryrefslogtreecommitdiff
path: root/src/libunixonacid/unixmessage_timed_receive.c
blob: dc83ff7f39c44f321b6cadb571a34367c00126f2 (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
30
/* ISC license. */

#include <sys/types.h>
#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 ssize_t 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_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ;
}