Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/dm utmpx support.



details:   https://anonhg.NetBSD.org/src/rev/d80578b74615
branches:  trunk
changeset: 534718:d80578b74615
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Aug 02 03:06:24 2002 +0000

description:
utmpx support.

diffstat:

 games/dm/Makefile |   6 +++++-
 games/dm/dm.c     |  24 ++++++++++++------------
 2 files changed, 17 insertions(+), 13 deletions(-)

diffs (74 lines):

diff -r 2282a11d0547 -r d80578b74615 games/dm/Makefile
--- a/games/dm/Makefile Fri Aug 02 02:52:07 2002 +0000
+++ b/games/dm/Makefile Fri Aug 02 03:06:24 2002 +0000
@@ -1,11 +1,15 @@
-#      $NetBSD: Makefile,v 1.8 1997/11/19 08:23:37 mrg Exp $
+#      $NetBSD: Makefile,v 1.9 2002/08/02 03:06:24 christos Exp $
 #      @(#)Makefile    8.1 (Berkeley) 5/31/93
 
 # -DLOG                log games
 PROG=  dm
+SRCS=  dm.c utmpentry.c
 MAN=   dm.8 dm.conf.5
 # shouldn't be necessary; just in case.
 BINGRP= games
 BINMODE=2555
 
+.PATH.c: ${.CURDIR}/../../usr.bin/who
+CPPFLAGS+=-I${.CURDIR}/../../usr.bin/who -DSUPPORT_UTMPX -DSUPPORT_UTMP
+
 .include <bsd.prog.mk>
diff -r 2282a11d0547 -r d80578b74615 games/dm/dm.c
--- a/games/dm/dm.c     Fri Aug 02 02:52:07 2002 +0000
+++ b/games/dm/dm.c     Fri Aug 02 03:06:24 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dm.c,v 1.16 2001/01/25 20:41:41 jdolecek Exp $ */
+/*     $NetBSD: dm.c,v 1.17 2002/08/02 03:06:24 christos Exp $ */
 
 /*
  * Copyright (c) 1987, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)dm.c       8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: dm.c,v 1.16 2001/01/25 20:41:41 jdolecek Exp $");
+__RCSID("$NetBSD: dm.c,v 1.17 2002/08/02 03:06:24 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -61,8 +61,8 @@
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
-#include <utmp.h>
 
+#include "utmpentry.h"
 #include "pathnames.h"
 
 static time_t  now;                    /* current time value */
@@ -256,16 +256,16 @@
 int
 users()
 {
-       
-       int nusers, utmp;
-       struct utmp buf;
+       static struct utmpentry *ohead = NULL;  
+       struct utmpentry *ep;
+       int nusers;
 
-       if ((utmp = open(_PATH_UTMP, O_RDONLY, 0)) < 0)
-               err(1, "%s", _PATH_UTMP);
-       for (nusers = 0; read(utmp, (char *)&buf, sizeof(struct utmp)) > 0;)
-               if (buf.ut_name[0] != '\0')
-                       ++nusers;
-       return (nusers);
+       nusers = getutentries(NULL, &ep);
+       if (ep != ohead) {
+               freeutentries(ep);
+               ohead = ep;
+       }
+       return nusers;
 }
 
 void



Home | Main Index | Thread Index | Old Index