diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2020-02-16 21:09:33 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2020-02-16 21:09:33 +0000 |
commit | ce03a1aff77e4a278a1fc4c887d9bcdfe7ab841e (patch) | |
tree | d4780c55ac87a57883e4dbde4d2bad18e6809b3e /usr.bin/dig | |
parent | 798719a464d5f63e923b0e8a6a9886a57ad88789 (diff) |
unravel isc_time_formattimestamp
OK millert
Diffstat (limited to 'usr.bin/dig')
-rw-r--r-- | usr.bin/dig/lib/isc/log.c | 10 | ||||
-rw-r--r-- | usr.bin/dig/lib/isc/unix/include/isc/time.h | 16 | ||||
-rw-r--r-- | usr.bin/dig/lib/isc/unix/time.c | 29 |
3 files changed, 9 insertions, 46 deletions
diff --git a/usr.bin/dig/lib/isc/log.c b/usr.bin/dig/lib/isc/log.c index 00762a6d894..0d47ea2bf22 100644 --- a/usr.bin/dig/lib/isc/log.c +++ b/usr.bin/dig/lib/isc/log.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: log.c,v 1.11 2020/02/16 21:08:59 florian Exp $ */ +/* $Id: log.c,v 1.12 2020/02/16 21:09:32 florian Exp $ */ /*! \file * \author Principal Authors: DCL */ @@ -943,11 +943,11 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, if ((channel->flags & ISC_LOG_PRINTTIME) != 0 && time_string[0] == '\0') { - struct timespec isctime; + struct timespec now; - TIME_NOW(&isctime); - isc_time_formattimestamp(&isctime, time_string, - sizeof(time_string)); + TIME_NOW(&now); + strftime(time_string, sizeof(time_string), + "%d-%b-%Y %X", localtime(&now.tv_sec)); } if ((channel->flags & ISC_LOG_PRINTLEVEL) != 0 && diff --git a/usr.bin/dig/lib/isc/unix/include/isc/time.h b/usr.bin/dig/lib/isc/unix/include/isc/time.h index dda34713ae4..ef3bb36b6bf 100644 --- a/usr.bin/dig/lib/isc/unix/include/isc/time.h +++ b/usr.bin/dig/lib/isc/unix/include/isc/time.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: time.h,v 1.11 2020/02/16 21:08:59 florian Exp $ */ +/* $Id: time.h,v 1.12 2020/02/16 21:09:32 florian Exp $ */ #ifndef ISC_TIME_H #define ISC_TIME_H 1 @@ -67,20 +67,6 @@ isc_time_microdiff(const struct timespec *t1, const struct timespec *t2); */ void -isc_time_formattimestamp(const struct timespec *t, char *buf, unsigned int len); -/*%< - * Format the time 't' into the buffer 'buf' of length 'len', - * using a format like "30-Aug-2000 04:06:47.997" and the local time zone. - * If the text does not fit in the buffer, the result is indeterminate, - * but is always guaranteed to be null terminated. - * - * Requires: - *\li 'len' > 0 - *\li 'buf' points to an array of at least len chars - * - */ - -void isc_time_formathttptimestamp(const struct timespec *t, char *buf, unsigned int len); /*%< * Format the time 't' into the buffer 'buf' of length 'len', diff --git a/usr.bin/dig/lib/isc/unix/time.c b/usr.bin/dig/lib/isc/unix/time.c index a0f60d032fd..bdc2ea89c0a 100644 --- a/usr.bin/dig/lib/isc/unix/time.c +++ b/usr.bin/dig/lib/isc/unix/time.c @@ -14,23 +14,19 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: time.c,v 1.14 2020/02/16 21:08:59 florian Exp $ */ +/* $Id: time.c,v 1.15 2020/02/16 21:09:32 florian Exp $ */ /*! \file */ - +#include <sys/time.h> #include <errno.h> #include <limits.h> #include <stdio.h> #include <time.h> - -#include <sys/time.h> /* Required for struct timeval on some platforms. */ - - #include <string.h> -#include <isc/time.h> +#include <isc/time.h> #include <isc/util.h> #define NS_PER_S 1000000000 /*%< Nanoseconds per second. */ @@ -72,25 +68,6 @@ isc_time_microdiff(const struct timespec *t1, const struct timespec *t2) { } void -isc_time_formattimestamp(const struct timespec *t, char *buf, unsigned int len) { - unsigned int flen; - - REQUIRE(t != NULL); - INSIST(t->tv_nsec < NS_PER_S); - REQUIRE(buf != NULL); - REQUIRE(len > 0); - - flen = strftime(buf, len, "%d-%b-%Y %X", localtime(&t->tv_sec)); - INSIST(flen < len); - if (flen != 0) { - snprintf(buf + flen, len - flen, - ".%03ld", t->tv_nsec / 1000000); - } else { - strlcpy(buf, "99-Bad-9999 99:99:99.999", len); - } -} - -void isc_time_formathttptimestamp(const struct timespec *t, char *buf, unsigned int len) { unsigned int flen; |