s6-tai64n.c (866B)
1 /* ISC license. */ 2 3 #include <sys/types.h> 4 #include <errno.h> 5 #include <skalibs/buffer.h> 6 #include <skalibs/strerr.h> 7 #include <skalibs/tai.h> 8 #include <skalibs/stralloc.h> 9 #include <skalibs/skamisc.h> 10 11 int main (void) 12 { 13 char stamp[TIMESTAMP+1] ; 14 PROG = "s6-tai64n" ; 15 stamp[TIMESTAMP] = ' ' ; 16 for (;;) 17 { 18 int r = skagetln(buffer_0f1, &satmp, '\n') ; 19 if (r < 0) 20 if (errno != EPIPE) 21 strerr_diefu1sys(111, "read from stdin") ; 22 else 23 { 24 r = 1 ; 25 if (!stralloc_catb(&satmp, "\n", 1)) 26 strerr_diefu1sys(111, "add newline") ; 27 } 28 else if (!r) break ; 29 timestamp(stamp) ; 30 if ((buffer_put(buffer_1, stamp, TIMESTAMP+1) < TIMESTAMP+1) 31 || (buffer_put(buffer_1, satmp.s, satmp.len) < (ssize_t)satmp.len)) 32 strerr_diefu1sys(111, "write to stdout") ; 33 satmp.len = 0 ; 34 } 35 return 0 ; 36 }