diff options
author | dillon <dillon@FreeBSD.org> | 2001-10-28 20:33:07 +0000 |
---|---|---|
committer | dillon <dillon@FreeBSD.org> | 2001-10-28 20:33:07 +0000 |
commit | 044c1da2a5568a722526096826be7c6275ec7dec (patch) | |
tree | 29fae15723b9a46495cedb74e0b0ce27ad0c0d32 | |
parent | a3b99516b8f4b21b7a6b046db9ae23969e1b9fa0 (diff) | |
download | FreeBSD-src-044c1da2a5568a722526096826be7c6275ec7dec.zip FreeBSD-src-044c1da2a5568a722526096826be7c6275ec7dec.tar.gz |
Convert time_t to/from 32 bit representations for transmission over
a network and storage.
-rw-r--r-- | usr.sbin/rwhod/rwhod.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.sbin/rwhod/rwhod.c b/usr.sbin/rwhod/rwhod.c index f54ed7ff..88e85bc 100644 --- a/usr.sbin/rwhod/rwhod.c +++ b/usr.sbin/rwhod/rwhod.c @@ -269,6 +269,7 @@ main(argc, argv) for (;;) { struct whod wd; int cc, whod, len = sizeof(from); + time_t t; cc = recvfrom(s, (char *)&wd, sizeof(struct whod), 0, (struct sockaddr *)&from, &len); @@ -325,7 +326,8 @@ main(argc, argv) } } #endif - (void) time((time_t *)&wd.wd_recvtime); + (void) time(&t); + wd.wd_recvtime = time_to_int(t); (void) write(whod, (char *)&wd, cc); if (fstat(whod, &st) < 0 || st.st_size > cc) ftruncate(whod, cc); @@ -462,7 +464,7 @@ onalrm(signo) for (i = 0; i < 3; i++) mywd.wd_loadav[i] = htonl((u_long)(avenrun[i] * 100)); cc = (char *)we - (char *)&mywd; - mywd.wd_sendtime = htonl(time(0)); + mywd.wd_sendtime = htonl(time_to_time32(time(NULL))); mywd.wd_vers = WHODVERSION; mywd.wd_type = WHODTYPE_STATUS; if (multicast_mode == SCOPED_MULTICAST) { @@ -512,7 +514,7 @@ getboottime(signo) syslog(LOG_ERR, "cannot get boottime: %m"); exit(1); } - mywd.wd_boottime = htonl(tm.tv_sec); + mywd.wd_boottime = htonl(time_to_time32(tm.tv_sec)); } void @@ -700,7 +702,7 @@ Sendto(s, buf, cc, flags, to, tolen) ntohl(w->wd_loadav[2]) / 100.0); cc -= WHDRSIZE; for (we = w->wd_we, cc /= sizeof(struct whoent); cc > 0; cc--, we++) { - time_t t = ntohl(we->we_utmp.out_time); + time_t t = time32_to_time(ntohl(we->we_utmp.out_time)); printf("%-8.8s %s:%s %.12s", we->we_utmp.out_name, w->wd_hostname, we->we_utmp.out_line, |