skalibs

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

textmessage_timed_receive.c (731B)


      1 /* ISC license. */
      2 
      3 #include <sys/uio.h>
      4 
      5 #include <skalibs/functypes.h>
      6 #include <skalibs/unix-timed.h>
      7 #include <skalibs/textmessage.h>
      8 
      9 typedef struct textmessage_getter_s textmessage_getter, *textmessage_getter_ref ;
     10 struct textmessage_getter_s
     11 {
     12   textmessage_receiver *tr ;
     13   struct iovec *v ;
     14 } ;
     15 
     16 static int getfd (textmessage_getter *g)
     17 {
     18   return textmessage_receiver_fd(g->tr) ;
     19 }
     20 
     21 static ssize_t get (textmessage_getter *g)
     22 {
     23   return textmessage_receive(g->tr, g->v) ;
     24 }
     25 
     26 int textmessage_timed_receive (textmessage_receiver *tr, struct iovec *v, tain const *deadline, tain *stamp)
     27 {
     28   textmessage_getter g = { .tr = tr, .v = v } ;
     29   return timed_get(&g, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ;
     30 }