timed_getln.c (715B)
1 /* ISC license. */ 2 3 #include <sys/types.h> 4 #include <skalibs/allreadwrite.h> 5 #include <skalibs/buffer.h> 6 #include <skalibs/functypes.h> 7 #include <skalibs/skamisc.h> 8 #include <skalibs/stralloc.h> 9 #include <skalibs/unix-timed.h> 10 11 struct blah_s 12 { 13 buffer *b ; 14 stralloc *sa ; 15 char sep ; 16 } ; 17 18 static int getfd (struct blah_s *blah) 19 { 20 return buffer_fd(blah->b) ; 21 } 22 23 static ssize_t get (struct blah_s *blah) 24 { 25 return sanitize_read(skagetln(blah->b, blah->sa, blah->sep)) ; 26 } 27 28 int timed_getln (buffer *b, stralloc *sa, char sep, tain const *deadline, tain *stamp) 29 { 30 struct blah_s blah = { .b = b, .sa = sa, .sep = sep } ; 31 return timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; 32 }