Sync usage with man page.
[netbsd-mini2440.git] / dist / ntp / libntp / tvtoa.c
blob9849c513fc179bee87be929daff062ebe30b5e9b
1 /* $NetBSD$ */
3 /*
4 * tvtoa - return an asciized representation of a struct timeval
5 */
7 #include "lib_strbuf.h"
9 #if defined(VMS)
10 # include "ntp_fp.h"
11 #endif /* VMS */
12 #include "ntp_stdlib.h"
13 #include "ntp_unixtime.h"
15 #include <stdio.h>
17 char *
18 tvtoa(
19 const struct timeval *tv
22 register char *buf;
23 register u_long sec;
24 register u_long usec;
25 register int isneg;
27 if (tv->tv_sec < 0 || tv->tv_usec < 0) {
28 sec = -tv->tv_sec;
29 usec = -tv->tv_usec;
30 isneg = 1;
31 } else {
32 sec = tv->tv_sec;
33 usec = tv->tv_usec;
34 isneg = 0;
37 LIB_GETBUF(buf);
39 (void) sprintf(buf, "%s%lu.%06lu", (isneg?"-":""), sec, usec);
40 return buf;