diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-02-11 03:12:21 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-02-11 03:12:21 +0000 |
commit | 774654ad56fc9304e4a064232760835c7a2a6c13 (patch) | |
tree | 3f539521073866497ff0370d8a6464c9356cadb4 /src/skaembutils/s6-tai64ndiff.c | |
parent | 790c8681d3451b61a536871dad234fc294796fd8 (diff) | |
download | s6-portable-utils-774654ad56fc9304e4a064232760835c7a2a6c13.tar.xz |
Add multicall configuration
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/skaembutils/s6-tai64ndiff.c')
-rw-r--r-- | src/skaembutils/s6-tai64ndiff.c | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/src/skaembutils/s6-tai64ndiff.c b/src/skaembutils/s6-tai64ndiff.c deleted file mode 100644 index cb35b4e..0000000 --- a/src/skaembutils/s6-tai64ndiff.c +++ /dev/null @@ -1,74 +0,0 @@ -/* ISC license. */ - -#include <stdint.h> -#include <string.h> -#include <errno.h> - -#include <skalibs/uint32.h> -#include <skalibs/uint64.h> -#include <skalibs/buffer.h> -#include <skalibs/strerr.h> -#include <skalibs/tai.h> -#include <skalibs/stralloc.h> -#include <skalibs/skamisc.h> - -int main (int argc, char const *const *argv) -{ - stralloc sa = STRALLOC_ZERO ; - tain prev ; - int defined = 0 ; - PROG = "s6-tai64ndiff" ; - - for (;;) - { - unsigned int p = 0 ; - char prefix[23] = "[ . ]" ; - int r = skagetln(buffer_0f1, &sa, '\n') ; - if (r == -1) - if (errno != EPIPE) - strerr_diefu1sys(111, "read from stdin") ; - else r = 1 ; - else if (!r) break ; - if (sa.len > TIMESTAMP) - { - tain cur ; - p = timestamp_scan(sa.s, &cur) ; - if (p) - { - if (defined) - { - tain diff ; - int64_t secs ; - size_t len ; - tain_sub(&diff, &cur, &prev) ; - secs = tai_sec(tain_secp(&diff)) ; - len = int64_fmt(0, secs) ; - if (len > 10) - { - char fmtn[9] ; - size_t m = 1 + (len < 20) ; - m += int64_fmt(prefix + m, secs) ; - prefix[m++] = '.' ; - uint320_fmt(fmtn, tain_nano(&diff), 9) ; - memcpy(prefix + m, fmtn, 22 - m) ; - } - else - { - int64_fmt(prefix + 11 - len, secs) ; - uint320_fmt(prefix + 12, tain_nano(&diff), 9) ; - } - } - prev = cur ; - defined = 1 ; - if (buffer_put(buffer_1, prefix, 23) < 23) - strerr_diefu1sys(111, "write to stdout") ; - } - else defined = 0 ; - } - else defined = 0 ; - if (buffer_put(buffer_1, sa.s + p, sa.len - p) < (ssize_t)(sa.len - p)) - strerr_diefu1sys(111, "write to stdout") ; - sa.len = 0 ; - } - return 0 ; -} |