added depend label
[unix-history] / usr / src / usr.bin / rwho / rwho.c
index d381429..c71b64a 100644 (file)
@@ -1,11 +1,23 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1983 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif not lint
+
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)rwho.c     4.9 (Berkeley) 84/12/05";
-#endif
+static char sccsid[] = "@(#)rwho.c     5.2 (Berkeley) %G%";
+#endif not lint
 
 #include <sys/param.h>
 #include <stdio.h>
 #include <sys/dir.h>
 
 #include <sys/param.h>
 #include <stdio.h>
 #include <sys/dir.h>
-#include "../etc/rwhod/rwhod.h"
+#include <protocols/rwhod.h>
 
 DIR    *dirp;
 
 
 DIR    *dirp;
 
@@ -21,6 +33,10 @@ int  nusers;
 
 #define        WHDRSIZE        (sizeof (wd) - sizeof (wd.wd_we))
 #define        RWHODIR         "/usr/spool/rwho"
 
 #define        WHDRSIZE        (sizeof (wd) - sizeof (wd.wd_we))
 #define        RWHODIR         "/usr/spool/rwho"
+/* 
+ * this macro should be shared with ruptime.
+ */
+#define        down(w,now)     ((now) - (w)->wd_recvtime > 11 * 60)
 
 char   *ctime(), *strcpy();
 int    now;
 
 char   *ctime(), *strcpy();
 int    now;
@@ -68,7 +84,7 @@ again:
                        (void) close(f);
                        continue;
                }
                        (void) close(f);
                        continue;
                }
-               if (now - w->wd_recvtime > 5 * 60) {
+               if (down(w,now)) {
                        (void) close(f);
                        continue;
                }
                        (void) close(f);
                        continue;
                }
@@ -100,8 +116,8 @@ again:
        }
        mp = myutmp;
        for (i = 0; i < nusers; i++) {
        }
        mp = myutmp;
        for (i = 0; i < nusers; i++) {
-               char buf[22];
-               sprintf(buf, "%s:%s", mp->myhost, mp->myutmp.out_line);
+               char buf[BUFSIZ];
+               (void)sprintf(buf, "%s:%s", mp->myhost, mp->myutmp.out_line);
                printf("%-8.8s %-*s %.12s",
                   mp->myutmp.out_name,
                   width,
                printf("%-8.8s %-*s %.12s",
                   mp->myutmp.out_name,
                   width,