From 90b12bd71bb9fc79a4640b9112c13ef529d0196a Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 5 Dec 2014 22:26:11 +0000 Subject: Initial commit --- src/daemontools-extras/s6-tai64n.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/daemontools-extras/s6-tai64n.c (limited to 'src/daemontools-extras/s6-tai64n.c') diff --git a/src/daemontools-extras/s6-tai64n.c b/src/daemontools-extras/s6-tai64n.c new file mode 100644 index 0000000..085c053 --- /dev/null +++ b/src/daemontools-extras/s6-tai64n.c @@ -0,0 +1,35 @@ +/* ISC license. */ + +#include +#include +#include +#include +#include +#include + +int main (void) +{ + char stamp[TIMESTAMP+1] ; + PROG = "s6-tai64n" ; + stamp[TIMESTAMP] = ' ' ; + for (;;) + { + register int r = skagetln(buffer_0f1, &satmp, '\n') ; + if (r < 0) + if (errno != EPIPE) + strerr_diefu1sys(111, "read from stdin") ; + else + { + r = 1 ; + if (!stralloc_catb(&satmp, "\n", 1)) + strerr_diefu1sys(111, "add newline") ; + } + else if (!r) break ; + timestamp(stamp) ; + if ((buffer_put(buffer_1, stamp, TIMESTAMP+1) < 0) + || (buffer_put(buffer_1, satmp.s, satmp.len) < 0)) + strerr_diefu1sys(111, "write to stdout") ; + satmp.len = 0 ; + } + return 0 ; +} -- cgit v1.2.3