skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

ipc_timed_recv.c (671B)


      1 /* ISC license. */
      2 
      3 #include <skalibs/functypes.h>
      4 #include <skalibs/allreadwrite.h>
      5 #include <skalibs/socket.h>
      6 #include <skalibs/unix-timed.h>
      7 
      8 struct blah_s
      9 {
     10   int fd ;
     11   char *s ;
     12   size_t len ;
     13   char *path ;
     14 } ;
     15 
     16 static int getfd (struct blah_s *blah)
     17 {
     18   return blah->fd ;
     19 }
     20 
     21 static ssize_t get (struct blah_s *blah)
     22 {
     23   return sanitize_read(ipc_recv(blah->fd, blah->s, blah->len, blah->path)) ;
     24 }
     25 
     26 ssize_t ipc_timed_recv (int fd, char *s, size_t len, char *path, tain const *deadline, tain *stamp)
     27 {
     28   struct blah_s blah = { .fd = fd, .s = s, .len = len, .path = path } ;
     29   return timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ;
     30 }