Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/gen make this behave like utmp, ie. return all entr...



details:   https://anonhg.NetBSD.org/src/rev/c73615e6c398
branches:  trunk
changeset: 534508:c73615e6c398
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Jul 28 20:46:43 2002 +0000

description:
make this behave like utmp, ie. return all entries and setutent() rewinds.

diffstat:

 lib/libc/gen/utmp.c |  21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diffs (48 lines):

diff -r cc957d1082df -r c73615e6c398 lib/libc/gen/utmp.c
--- a/lib/libc/gen/utmp.c       Sun Jul 28 19:54:47 2002 +0000
+++ b/lib/libc/gen/utmp.c       Sun Jul 28 20:46:43 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: utmp.c,v 1.1 2002/07/27 23:57:39 christos Exp $         */
+/*     $NetBSD: utmp.c,v 1.2 2002/07/28 20:46:43 christos Exp $         */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include <sys/cdefs.h>
 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: utmp.c,v 1.1 2002/07/27 23:57:39 christos Exp $");
+__RCSID("$NetBSD: utmp.c,v 1.2 2002/07/28 20:46:43 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <stdio.h>
@@ -51,21 +51,20 @@
 void
 setutent(void)
 {
-       if (ut != NULL)
-               (void)fclose(ut);
-       ut = fopen(_PATH_UTMP, "r");
+       if (ut == NULL)
+               return;
+       (void)fseeko(ut, (off_t)0, SEEK_SET);
 }
 
 struct utmp *
 getutent(void)
 {
-       if (ut == NULL)
-               return NULL;
-       while (fread(&utmp, sizeof(utmp), 1, ut) == 1) {
-               if (utmp.ut_name[0] == '\0')
-                       continue;
+       if (ut == NULL) {
+               if ((ut = fopen(_PATH_UTMP, "r")) == NULL)
+                       return NULL;
+       }
+       if (fread(&utmp, sizeof(utmp), 1, ut) == 1)
                return &utmp;
-       }
        return NULL;
 }
 



Home | Main Index | Thread Index | Old Index