Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/last use sockaddr_snprintf()



details:   https://anonhg.NetBSD.org/src/rev/f3c8ad918bc5
branches:  trunk
changeset: 571362:f3c8ad918bc5
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Nov 19 21:41:25 2004 +0000

description:
use sockaddr_snprintf()

diffstat:

 usr.bin/last/Makefile |   5 ++++-
 usr.bin/last/last.c   |   5 +++--
 usr.bin/last/want.c   |  25 ++++---------------------
 3 files changed, 11 insertions(+), 24 deletions(-)

diffs (80 lines):

diff -r 89e40c46e0e3 -r f3c8ad918bc5 usr.bin/last/Makefile
--- a/usr.bin/last/Makefile     Fri Nov 19 21:39:03 2004 +0000
+++ b/usr.bin/last/Makefile     Fri Nov 19 21:41:25 2004 +0000
@@ -1,7 +1,10 @@
-#      $NetBSD: Makefile,v 1.6 2003/02/17 15:08:57 christos Exp $
+#      $NetBSD: Makefile,v 1.7 2004/11/19 21:41:25 christos Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/6/93
 
 PROG=  last
 CPPFLAGS+=-DSUPPORT_UTMPX -DSUPPORT_UTMP
 
+LDADD=-lutil
+DPADD=${LIBUTIL}
+
 .include <bsd.prog.mk>
diff -r 89e40c46e0e3 -r f3c8ad918bc5 usr.bin/last/last.c
--- a/usr.bin/last/last.c       Fri Nov 19 21:39:03 2004 +0000
+++ b/usr.bin/last/last.c       Fri Nov 19 21:41:25 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: last.c,v 1.24 2004/11/11 01:01:22 wiz Exp $    */
+/*     $NetBSD: last.c,v 1.25 2004/11/19 21:41:25 christos Exp $       */
 
 /*
  * Copyright (c) 1987, 1993, 1994
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = "@(#)last.c     8.2 (Berkeley) 4/2/94";
 #endif
-__RCSID("$NetBSD: last.c,v 1.24 2004/11/11 01:01:22 wiz Exp $");
+__RCSID("$NetBSD: last.c,v 1.25 2004/11/19 21:41:25 christos Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -63,6 +63,7 @@
 #ifdef SUPPORT_UTMP
 #include <utmp.h>
 #endif
+#include <util.h>
 
 #ifndef UT_NAMESIZE
 #define UT_NAMESIZE 8
diff -r 89e40c46e0e3 -r f3c8ad918bc5 usr.bin/last/want.c
--- a/usr.bin/last/want.c       Fri Nov 19 21:39:03 2004 +0000
+++ b/usr.bin/last/want.c       Fri Nov 19 21:41:25 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: want.c,v 1.3 2004/11/11 00:54:23 christos Exp $        */
+/*     $NetBSD: want.c,v 1.4 2004/11/19 21:41:25 christos Exp $        */
 
 /*
  * Copyright (c) 1987, 1993, 1994
@@ -42,26 +42,9 @@
 #else
        if (numeric) {
                static char buf[512];
-               const char *p;
-               struct sockaddr_storage *ss = &ut->ut_ss;
-               void *a;
-               switch (ss->ss_family) {
-               default:
-                       (void)snprintf(buf, sizeof(buf), "%d: unknown family",
-                               ss->ss_family);
-                       return buf;
-               case 0: /* reboot etc. entries */
-                       return "";
-               case AF_INET:
-                       a = &((struct sockaddr_in *)(void *)ss)->sin_addr;
-                       break;
-               case AF_INET6:
-                       a = &((struct sockaddr_in6 *)(void *)ss)->sin6_addr;
-                       break;
-               }
-               if ((p = inet_ntop(ss->ss_family, a, buf, ss->ss_len)) != NULL)
-                       return p;
-               (void)snprintf(buf, sizeof(buf), "%s", strerror(errno));
+               buf[0] = '\0';
+               (void)sockaddr_snprintf(buf, sizeof(buf), "%a",
+                   (struct sockaddr *)&ut->ut_ss);
                return buf;
        } else
                return ut->ut_host;



Home | Main Index | Thread Index | Old Index