diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2014-12-15 23:08:59 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2014-12-15 23:08:59 +0000 |
commit | e0fc82203d677a6f1e808e9a1a46176c109d89be (patch) | |
tree | e9609209b755e3f7a8480aea86601ffe9d4ca540 /src/clock/s6-clockview.c | |
download | s6-networking-e0fc82203d677a6f1e808e9a1a46176c109d89be.tar.xz |
Initial commit
Diffstat (limited to 'src/clock/s6-clockview.c')
-rw-r--r-- | src/clock/s6-clockview.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/clock/s6-clockview.c b/src/clock/s6-clockview.c new file mode 100644 index 0000000..3600cce --- /dev/null +++ b/src/clock/s6-clockview.c @@ -0,0 +1,31 @@ +/* ISC license. */ + +#include <skalibs/allreadwrite.h> +#include <skalibs/buffer.h> +#include <skalibs/strerr2.h> +#include <skalibs/tai.h> +#include <skalibs/djbtime.h> + +int main (void) +{ + char buf[TAIN_PACK] ; + tain_t now, adj ; + localtmn_t l ; + char fmt[LOCALTMN_FMT] ; + PROG = "s6-clockview" ; + + if (allread(0, buf, TAIN_PACK) < TAIN_PACK) strerr_diefu1sys(111, "read from stdin") ; + tain_unpack(buf, &adj) ; + if (!sysclock_get(&now)) strerr_diefu1sys(111, "sysclock_get") ; + if (!localtmn_from_sysclock(&l, &now, 1)) strerr_diefu1sys(111, "localtmn_from_sysclock") ; + if (buffer_puts(buffer_1, "before: ") < 0) goto fail ; + if (buffer_put(buffer_1, fmt, localtmn_fmt(fmt, &l)) < 0) goto fail ; + tain_add(&now, &now, &adj) ; + if (!localtmn_from_sysclock(&l, &now, 1)) strerr_diefu1sys(111, "localtmn_from_sysclock") ; + if (buffer_puts(buffer_1, "\nafter: ") < 0) goto fail ; + if (buffer_put(buffer_1, fmt, localtmn_fmt(fmt, &l)) < 0) goto fail ; + if (buffer_putflush(buffer_1, "\n", 1) < 0) goto fail ; + return 0 ; + fail: + strerr_diefu1sys(111, "write to stdout") ; +} |