Module Name:    src
Committed By:   christos
Date:           Wed Dec 13 17:42:44 UTC 2017

Modified Files:
        src/sbin/route: Makefile route.c

Log Message:
Use the definitions from the standard header files and replace homebrew
snprintb with the libutil one.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sbin/route/Makefile
cvs rdiff -u -r1.157 -r1.158 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/Makefile
diff -u src/sbin/route/Makefile:1.30 src/sbin/route/Makefile:1.31
--- src/sbin/route/Makefile:1.30	Tue Oct 10 15:30:06 2017
+++ src/sbin/route/Makefile	Wed Dec 13 12:42:44 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.30 2017/10/10 19:30:06 christos Exp $
+#	$NetBSD: Makefile,v 1.31 2017/12/13 17:42:44 christos Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 .include <bsd.own.mk>
@@ -17,6 +17,9 @@ DPADD.rump += ${LIBRUMPRES}
 CPPFLAGS+=-DINET6
 .endif
 
+LDADD+=-lutil
+DPADD+=${LIBUTIL}
+
 # The Makefile over in ../../distrib/utils/x_route
 # would like keywords.[ch] to always exist here, so
 # they are now checked in as sources.

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.157 src/sbin/route/route.c:1.158
--- src/sbin/route/route.c:1.157	Wed Dec 13 06:31:42 2017
+++ src/sbin/route/route.c	Wed Dec 13 12:42:44 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.157 2017/12/13 11:31:42 uwe Exp $	*/
+/*	$NetBSD: route.c,v 1.158 2017/12/13 17:42:44 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)route.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: route.c,v 1.157 2017/12/13 11:31:42 uwe Exp $");
+__RCSID("$NetBSD: route.c,v 1.158 2017/12/13 17:42:44 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -68,6 +68,7 @@ __RCSID("$NetBSD: route.c,v 1.157 2017/1
 #include <time.h>
 #include <paths.h>
 #include <err.h>
+#include <util.h>
 
 #include "keywords.h"
 #include "extern.h"
@@ -1291,14 +1292,10 @@ const char * const msgtypes[] = {
 	[RTM_CHGADDR] = "RTM_CHGADDR: address being changed on iface",
 };
 
-const char metricnames[] =
-"\011pksent\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire\2hopcount\1mtu";
-const char routeflags[] =
-"\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE\010MASK_PRESENT\011CONNECTED\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016CLONED\017PROTO2\020PROTO1\023LOCAL\024BROADCAST";
-const char ifnetflags[] =
-"\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6NOTRAILERS\7RUNNING\010NOARP\011PROMISC\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1\017LINK2\020MULTICAST";
-const char addrnames[] =
-"\1DST\2GATEWAY\3NETMASK\4GENMASK\5IFP\6IFA\7AUTHOR\010BRD\011TAG";
+const char metricnames[] = RTVBITS;
+const char routeflags[] = RTFBITS;
+const char ifnetflags[] = IFFBITS;
+const char addrnames[] = RTABITS;
 
 
 #ifndef SMALL
@@ -1659,30 +1656,10 @@ pmsg_addrs(const char *cp, int addrs)
 static void
 bprintf(FILE *fp, int b, const char *f)
 {
-	int i;
-	int gotsome = 0;
-	const uint8_t *s = (const uint8_t *)f;
+	char buf[1024];
 
-	if (b == 0) {
-		fputs("none", fp);
-		return;
-	}
-	while ((i = *s++) != 0) {
-		if (b & (1 << (i-1))) {
-			if (gotsome == 0)
-				i = '<';
-			else
-				i = ',';
-			(void)putc(i, fp);
-			gotsome = 1;
-			for (; (i = *s) > 32; s++)
-				(void)putc(i, fp);
-		} else
-			while (*s > 32)
-				s++;
-	}
-	if (gotsome)
-		(void)putc('>', fp);
+	snprintb(buf, sizeof(buf), f, b);
+	fputs(buf, fp);
 }
 
 int

Reply via email to