]> mj.ucw.cz Git - nwho.git/blobdiff - nwho.c
Remember down servers for some time.
[nwho.git] / nwho.c
diff --git a/nwho.c b/nwho.c
index 505309c35ebc0b010353233af1b677a2277bdc8f..3adb1ec3b6dee1deed0e3026dbfc07c4effd2526 100644 (file)
--- a/nwho.c
+++ b/nwho.c
@@ -1,7 +1,7 @@
 /*
- *     The Remote User Information Lister 1.9
+ *     The Remote User Information Lister
  *
- *     (c) 1997--2001 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ *     (c) 1997--2002 Martin Mares <mj@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU General Public License. See file COPYING in any of the GNU packages.
 #include <fcntl.h>
 #include <unistd.h>
 #include <dirent.h>
+#include <time.h>
 #include <netinet/in.h>
 #include <asm/types.h>
 
 #include "net.h"
 
 static int is_uptime;
+static time_t now;
 
 static void
 puttime(int s)
@@ -51,6 +53,11 @@ show_uptime(char *name, struct rywho_pkt *p)
 {
   int i;
 
+  if (p->server_time - now >= DEFAULT_DOWN_TIME)
+    {
+      printf("%-16s down\n", name);
+      return;
+    }
   printf("%-16s up ", name);
   puttime(ntohl(p->uptime));
   printf("  load");
@@ -69,6 +76,8 @@ show_users(char *name, struct rywho_pkt *p)
   int m = ntohl(p->num_users);
   struct userinfo *i;
 
+  if (p->server_time - now >= DEFAULT_DOWN_TIME)
+    return;
   for(u=0; u<m; u++)
     {
       i = &p->users[u];
@@ -140,6 +149,7 @@ main(int argc, char **argv)
     }
   if (!is_uptime)
     puts("Name     Li      M Where            LogT  IdleT");
+  now = time(NULL);
   scan();
   return 0;
 }