unixmessage_timed_handle.c (832B)
1 /* ISC license. */ 2 3 #include <skalibs/functypes.h> 4 #include <skalibs/unix-timed.h> 5 #include <skalibs/unixmessage.h> 6 7 typedef struct unixmessage_handler_blah_s unixmessage_handler_blah, *unixmessage_handler_blah_ref ; 8 struct unixmessage_handler_blah_s 9 { 10 unixmessage_receiver *b ; 11 unixmessage_handler_func_ref f ; 12 void *p ; 13 } ; 14 15 static int getfd (unixmessage_handler_blah *blah) 16 { 17 return unixmessage_receiver_fd(blah->b) ; 18 } 19 20 static ssize_t get (unixmessage_handler_blah *blah) 21 { 22 return unixmessage_handle(blah->b, blah->f, blah->p) ; 23 } 24 25 int unixmessage_timed_handle (unixmessage_receiver *b, unixmessage_handler_func_ref f, void *p, tain const *deadline, tain *stamp) 26 { 27 unixmessage_handler_blah blah = { .b = b, .f = f, .p = p } ; 28 return timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; 29 }