summaryrefslogtreecommitdiff
path: root/src/libunixonacid/textmessage_timed_receive.c
blob: fe02080ba3a8555596f0ca6f7c20a01d508d3042 (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/uio.h>

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

typedef struct textmessage_getter_s textmessage_getter, *textmessage_getter_ref ;
struct textmessage_getter_s
{
  textmessage_receiver *tr ;
  struct iovec *v ;
} ;

static int getfd (textmessage_getter *g)
{
  return textmessage_receiver_fd(g->tr) ;
}

static ssize_t get (textmessage_getter *g)
{
  return textmessage_receive(g->tr, g->v) ;
}

int textmessage_timed_receive (textmessage_receiver *tr, struct iovec *v, tain const *deadline, tain *stamp)
{
  textmessage_getter g = { .tr = tr, .v = v } ;
  return timed_get(&g, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ;
}