skalibs

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

textmessage_timed_handle.c (838B)


      1 /* ISC license. */
      2 
      3 #include <skalibs/functypes.h>
      4 #include <skalibs/unix-timed.h>
      5 #include <skalibs/textmessage.h>
      6 
      7 typedef struct textmessage_handler_blah_s textmessage_handler_blah, *textmessage_handler_blah_ref ;
      8 struct textmessage_handler_blah_s
      9 {
     10   textmessage_receiver *tr ;
     11   textmessage_handler_func_ref f ;
     12   void *p ;
     13 } ;
     14 
     15 static int getfd (textmessage_handler_blah *blah)
     16 {
     17   return textmessage_receiver_fd(blah->tr) ;
     18 }
     19 
     20 static ssize_t get (textmessage_handler_blah *blah)
     21 {
     22   return textmessage_handle(blah->tr, blah->f, blah->p) ;
     23 }
     24 
     25 int textmessage_timed_handle (textmessage_receiver *tr, textmessage_handler_func_ref f, void *p, tain const *deadline, tain *stamp)
     26 {
     27   textmessage_handler_blah blah = { .tr = tr, .f = f, .p = p } ;
     28   return timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ;
     29 }