diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-09-07 07:52:15 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-09-07 07:52:15 +0000 |
commit | af92d59f0c404fa53091253c6666c5d613979e47 (patch) | |
tree | 92fe757fbffb5671dc4335c7cb74c26b48423e8e /usr.sbin/relayd/log.c | |
parent | 8ecd9f570ea5c0896b736732748ae9beb6cdec22 (diff) |
add a function to print delays in hours, minutes, and seconds
Diffstat (limited to 'usr.sbin/relayd/log.c')
-rw-r--r-- | usr.sbin/relayd/log.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/usr.sbin/relayd/log.c b/usr.sbin/relayd/log.c index b6f8ae4cd05..5b7257a0d09 100644 --- a/usr.sbin/relayd/log.c +++ b/usr.sbin/relayd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.6 2007/09/06 19:55:45 reyk Exp $ */ +/* $OpenBSD: log.c,v 1.7 2007/09/07 07:52:14 reyk Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -230,3 +230,19 @@ print_host(struct sockaddr_storage *ss, char *buf, size_t len) ptr = &((struct sockaddr_in6 *)ss)->sin6_addr; return (inet_ntop(af, ptr, buf, len)); } + +const char * +print_time(struct timeval *a, struct timeval *b, char *buf, size_t len) +{ + struct timeval tv; + u_long h, sec, min; + + timerclear(&tv); + timersub(a, b, &tv); + sec = tv.tv_sec % 60; + min = tv.tv_sec / 60 % 60; + h = tv.tv_sec / 60 / 60; + + snprintf(buf, len, "%.2lu:%.2lu:%.2lu", h, min, sec); + return (buf); +} |