summaryrefslogtreecommitdiff
path: root/src/libwpactrl/wpactrl_fd_timed_recv.c
blob: dc50a915c1aeae2e8fe97ef9b64cc20805fce6eb (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/allreadwrite.h>
#include <skalibs/unix-timed.h>
#include "wpactrl-internal.h"

struct blah_s
{
  int fd ;
  char *s ;
  size_t len ;
} ;

static int getfd (struct blah_s *blah)
{
  return blah->fd ;
}

static ssize_t get (struct blah_s *blah)
{
  return sanitize_read(wpactrl_fd_recv(blah->fd, blah->s, blah->len)) ;
}

ssize_t wpactrl_fd_timed_recv (int fd, char *s, size_t len, tain const *deadline, tain *stamp)
{
  struct blah_s blah = { .fd = fd, .s = s, .len = len } ;
  return timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ;
}