Deleted Added
full compact
rwhod.c (85640) rwhod.c (89572)
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 28 unchanged lines hidden (view full) ---

37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static char sccsid[] = "@(#)rwhod.c 8.1 (Berkeley) 6/6/93";
43#endif
44static const char rcsid[] =
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 28 unchanged lines hidden (view full) ---

37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static char sccsid[] = "@(#)rwhod.c 8.1 (Berkeley) 6/6/93";
43#endif
44static const char rcsid[] =
45 "$FreeBSD: head/usr.sbin/rwhod/rwhod.c 85640 2001-10-28 20:33:07Z dillon $";
45 "$FreeBSD: head/usr.sbin/rwhod/rwhod.c 89572 2002-01-19 23:20:02Z dillon $";
46#endif /* not lint */
47
48#include <sys/param.h>
49#include <sys/socket.h>
50#include <sys/stat.h>
51#include <sys/signal.h>
52#include <sys/ioctl.h>
53#include <sys/sysctl.h>

--- 268 unchanged lines hidden (view full) ---

322 we->we_idle = ntohl(we->we_idle);
323 we->we_utmp.out_time =
324 ntohl(we->we_utmp.out_time);
325 we++;
326 }
327 }
328#endif
329 (void) time(&t);
46#endif /* not lint */
47
48#include <sys/param.h>
49#include <sys/socket.h>
50#include <sys/stat.h>
51#include <sys/signal.h>
52#include <sys/ioctl.h>
53#include <sys/sysctl.h>

--- 268 unchanged lines hidden (view full) ---

322 we->we_idle = ntohl(we->we_idle);
323 we->we_utmp.out_time =
324 ntohl(we->we_utmp.out_time);
325 we++;
326 }
327 }
328#endif
329 (void) time(&t);
330 wd.wd_recvtime = time_to_int(t);
330 wd.wd_recvtime = _time_to_int(t);
331 (void) write(whod, (char *)&wd, cc);
332 if (fstat(whod, &st) < 0 || st.st_size > cc)
333 ftruncate(whod, cc);
334 (void) close(whod);
335 }
336}
337
338static void

--- 120 unchanged lines hidden (view full) ---

459 if (stat(we->we_utmp.out_line, &stb) >= 0)
460 we->we_idle = htonl(now - stb.st_atime);
461 we++;
462 }
463 (void)getloadavg(avenrun, sizeof(avenrun)/sizeof(avenrun[0]));
464 for (i = 0; i < 3; i++)
465 mywd.wd_loadav[i] = htonl((u_long)(avenrun[i] * 100));
466 cc = (char *)we - (char *)&mywd;
331 (void) write(whod, (char *)&wd, cc);
332 if (fstat(whod, &st) < 0 || st.st_size > cc)
333 ftruncate(whod, cc);
334 (void) close(whod);
335 }
336}
337
338static void

--- 120 unchanged lines hidden (view full) ---

459 if (stat(we->we_utmp.out_line, &stb) >= 0)
460 we->we_idle = htonl(now - stb.st_atime);
461 we++;
462 }
463 (void)getloadavg(avenrun, sizeof(avenrun)/sizeof(avenrun[0]));
464 for (i = 0; i < 3; i++)
465 mywd.wd_loadav[i] = htonl((u_long)(avenrun[i] * 100));
466 cc = (char *)we - (char *)&mywd;
467 mywd.wd_sendtime = htonl(time_to_time32(time(NULL)));
467 mywd.wd_sendtime = htonl(_time_to_time32(time(NULL)));
468 mywd.wd_vers = WHODVERSION;
469 mywd.wd_type = WHODTYPE_STATUS;
470 if (multicast_mode == SCOPED_MULTICAST) {
471 (void) sendto(s, (char *)&mywd, cc, 0,
472 (struct sockaddr *)&multicast_addr,
473 sizeof(multicast_addr));
474 }
475 else for (np = neighbors; np != NULL; np = np->n_next) {

--- 33 unchanged lines hidden (view full) ---

509
510 mib[0] = CTL_KERN;
511 mib[1] = KERN_BOOTTIME;
512 size = sizeof(tm);
513 if (sysctl(mib, 2, &tm, &size, NULL, 0) == -1) {
514 syslog(LOG_ERR, "cannot get boottime: %m");
515 exit(1);
516 }
468 mywd.wd_vers = WHODVERSION;
469 mywd.wd_type = WHODTYPE_STATUS;
470 if (multicast_mode == SCOPED_MULTICAST) {
471 (void) sendto(s, (char *)&mywd, cc, 0,
472 (struct sockaddr *)&multicast_addr,
473 sizeof(multicast_addr));
474 }
475 else for (np = neighbors; np != NULL; np = np->n_next) {

--- 33 unchanged lines hidden (view full) ---

509
510 mib[0] = CTL_KERN;
511 mib[1] = KERN_BOOTTIME;
512 size = sizeof(tm);
513 if (sysctl(mib, 2, &tm, &size, NULL, 0) == -1) {
514 syslog(LOG_ERR, "cannot get boottime: %m");
515 exit(1);
516 }
517 mywd.wd_boottime = htonl(time_to_time32(tm.tv_sec));
517 mywd.wd_boottime = htonl(_time_to_time32(tm.tv_sec));
518}
519
520void
521quit(msg)
522 char *msg;
523{
524 syslog(LOG_ERR, "%s", msg);
525 exit(1);

--- 171 unchanged lines hidden (view full) ---

697 ntohs(sin->sin_port));
698 printf("hostname %s %s\n", w->wd_hostname,
699 interval(ntohl(w->wd_sendtime) - ntohl(w->wd_boottime), " up"));
700 printf("load %4.2f, %4.2f, %4.2f\n",
701 ntohl(w->wd_loadav[0]) / 100.0, ntohl(w->wd_loadav[1]) / 100.0,
702 ntohl(w->wd_loadav[2]) / 100.0);
703 cc -= WHDRSIZE;
704 for (we = w->wd_we, cc /= sizeof(struct whoent); cc > 0; cc--, we++) {
518}
519
520void
521quit(msg)
522 char *msg;
523{
524 syslog(LOG_ERR, "%s", msg);
525 exit(1);

--- 171 unchanged lines hidden (view full) ---

697 ntohs(sin->sin_port));
698 printf("hostname %s %s\n", w->wd_hostname,
699 interval(ntohl(w->wd_sendtime) - ntohl(w->wd_boottime), " up"));
700 printf("load %4.2f, %4.2f, %4.2f\n",
701 ntohl(w->wd_loadav[0]) / 100.0, ntohl(w->wd_loadav[1]) / 100.0,
702 ntohl(w->wd_loadav[2]) / 100.0);
703 cc -= WHDRSIZE;
704 for (we = w->wd_we, cc /= sizeof(struct whoent); cc > 0; cc--, we++) {
705 time_t t = time32_to_time(ntohl(we->we_utmp.out_time));
705 time_t t = _time32_to_time(ntohl(we->we_utmp.out_time));
706 printf("%-8.8s %s:%s %.12s",
707 we->we_utmp.out_name,
708 w->wd_hostname, we->we_utmp.out_line,
709 ctime(&t)+4);
710 we->we_idle = ntohl(we->we_idle) / 60;
711 if (we->we_idle) {
712 if (we->we_idle >= 100*60)
713 we->we_idle = 100*60 - 1;

--- 34 unchanged lines hidden ---
706 printf("%-8.8s %s:%s %.12s",
707 we->we_utmp.out_name,
708 w->wd_hostname, we->we_utmp.out_line,
709 ctime(&t)+4);
710 we->we_idle = ntohl(we->we_idle) / 60;
711 if (we->we_idle) {
712 if (we->we_idle >= 100*60)
713 we->we_idle = 100*60 - 1;

--- 34 unchanged lines hidden ---