]> mj.ucw.cz Git - nwho.git/blobdiff - nwho.c
Killed another reference to <asm/types.h>
[nwho.git] / nwho.c
diff --git a/nwho.c b/nwho.c
index 3adb1ec3b6dee1deed0e3026dbfc07c4effd2526..7edcd0cd521caaa07658f353a1cfe137ad550ecd 100644 (file)
--- a/nwho.c
+++ b/nwho.c
@@ -1,10 +1,7 @@
 /*
  *     The Remote User Information Lister
  *
- *     (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.
+ *     (c) 1997--2010 Martin Mares <mj@ucw.cz>
  */
 
 #include <stdio.h>
@@ -15,7 +12,6 @@
 #include <dirent.h>
 #include <time.h>
 #include <netinet/in.h>
-#include <asm/types.h>
 
 #include "net.h"
 
@@ -49,11 +45,11 @@ puttime(int s)
 }
 
 static void
-show_uptime(char *name, struct rywho_pkt *p)
+show_uptime(char *name, struct nwho_pkt *p)
 {
   int i;
 
-  if (p->server_time - now >= DEFAULT_DOWN_TIME)
+  if (now - ntohl(p->server_time) >= DEFAULT_DOWN_TIME)
     {
       printf("%-16s down\n", name);
       return;
@@ -70,13 +66,13 @@ show_uptime(char *name, struct rywho_pkt *p)
 }
 
 static void
-show_users(char *name, struct rywho_pkt *p)
+show_users(char *name, struct nwho_pkt *p)
 {
   int u;
   int m = ntohl(p->num_users);
   struct userinfo *i;
 
-  if (p->server_time - now >= DEFAULT_DOWN_TIME)
+  if (now - ntohl(p->server_time) >= DEFAULT_DOWN_TIME)
     return;
   for(u=0; u<m; u++)
     {
@@ -96,7 +92,7 @@ scan(void)
 {
   DIR *d;
   struct dirent *e;
-  struct rywho_pkt pkt;
+  struct nwho_pkt pkt;
   int fd, r;
   int is = 0;
 
@@ -122,9 +118,9 @@ scan(void)
          }
        r = read(fd, &pkt, sizeof(pkt));
        close(fd);
-       if (r < sizeof(struct rywho_pkt) - MAX_USERS*sizeof(struct userinfo)
+       if (r < sizeof(struct nwho_pkt) - MAX_USERS*sizeof(struct userinfo)
            || pkt.magic != htonl(NWHO_MAGIC)
-           || r != sizeof(struct rywho_pkt) - (MAX_USERS - ntohl(pkt.num_users))*sizeof(struct userinfo))
+           || r != sizeof(struct nwho_pkt) - (MAX_USERS - ntohl(pkt.num_users))*sizeof(struct userinfo))
          {
            fprintf(stderr, "%s: Malformed record\n", e->d_name);
            continue;