Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/blacklist/bin prettier display



details:   https://anonhg.NetBSD.org/src/rev/da58f8c4710b
branches:  trunk
changeset: 335845:da58f8c4710b
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Jan 26 02:31:52 2015 +0000

description:
prettier display

diffstat:

 external/bsd/blacklist/bin/blacklistctl.8 |  15 +++++++++++++--
 external/bsd/blacklist/bin/blacklistctl.c |  23 ++++++++++++++++-------
 2 files changed, 29 insertions(+), 9 deletions(-)

diffs (131 lines):

diff -r 6bc65a02f757 -r da58f8c4710b external/bsd/blacklist/bin/blacklistctl.8
--- a/external/bsd/blacklist/bin/blacklistctl.8 Mon Jan 26 00:34:50 2015 +0000
+++ b/external/bsd/blacklist/bin/blacklistctl.8 Mon Jan 26 02:31:52 2015 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: blacklistctl.8,v 1.3 2015/01/25 23:07:16 wiz Exp $
+.\" $NetBSD: blacklistctl.8,v 1.4 2015/01/26 02:31:52 christos Exp $
 .\"
 .\" Copyright (c) 2015 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 24, 2015
+.Dd January 25, 2015
 .Dt BLACKLISTCTL 8
 .Os
 .Sh NAME
@@ -35,8 +35,13 @@
 .Nd display and change the state of blacklistd
 .Sh SYNOPSIS
 .Nm
+<<<<<<< blacklistctl.8
+dump 
+.Op Fl abdnrw
+=======
 .Cm dump
 .Op Fl abdr
+>>>>>>> 1.3
 .Sh DESCRIPTION
 .Nm
 is a program used to display the state of
@@ -50,8 +55,14 @@
 Show only the blocked entries.
 .It Fl d
 Increase debugging level.
+.It Fl n
+Don't display a header.
 .It Fl r
 Show the remaining blocked time instead of the last activity time.
+.It Fl w
+Normally the width of addresses is good for IPv4, the
+.Fl w
+flag, makes the display wide enough for IPv6 addresses.
 .El
 .Sh SEE ALSO
 .Xr blacklistd 8
diff -r 6bc65a02f757 -r da58f8c4710b external/bsd/blacklist/bin/blacklistctl.c
--- a/external/bsd/blacklist/bin/blacklistctl.c Mon Jan 26 00:34:50 2015 +0000
+++ b/external/bsd/blacklist/bin/blacklistctl.c Mon Jan 26 02:31:52 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: blacklistctl.c,v 1.14 2015/01/24 15:33:03 christos Exp $       */
+/*     $NetBSD: blacklistctl.c,v 1.15 2015/01/26 02:31:52 christos Exp $       */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: blacklistctl.c,v 1.14 2015/01/24 15:33:03 christos Exp $");
+__RCSID("$NetBSD: blacklistctl.c,v 1.15 2015/01/26 02:31:52 christos Exp $");
 
 #include <stdio.h>
 #include <time.h>
@@ -60,7 +60,7 @@
                warnx("Missing/unknown command");
        else
                warnx("Unknown option `%c'", (char)c);
-       fprintf(stderr, "Usage: %s dump [-abdr]\n", getprogname());
+       fprintf(stderr, "Usage: %s dump [-abdnrw]\n", getprogname());
        exit(EXIT_FAILURE);
 }
 
@@ -74,10 +74,10 @@
        struct dbinfo dbi;
        unsigned int i;
        struct timespec ts;
-       int all, blocked, remain;
+       int all, blocked, remain, wide, noheader;
        int o;
 
-       blocked = all = remain = 0;
+       noheader = wide = blocked = all = remain = 0;
        lfun = dlog;
 
        if (argc == 1 || strcmp(argv[1], "dump") != 0)
@@ -86,7 +86,7 @@
        argc--;
        argv++;
 
-       while ((o = getopt(argc, argv, "abdr")) != -1)
+       while ((o = getopt(argc, argv, "abdrw")) != -1)
                switch (o) {
                case 'a':
                        all = 1;
@@ -98,9 +98,14 @@
                case 'd':
                        debug++;
                        break;
+               case 'n':
+                       noheader = 1;
                case 'r':
                        remain = 1;
                        break;
+               case 'w':
+                       wide = 1;
+                       break;
                default:
                        usage(o);
                        break;
@@ -111,6 +116,10 @@
                err(EXIT_FAILURE, "Can't open `%s'", dbname);
 
        clock_gettime(CLOCK_REALTIME, &ts);
+       wide = wide ? 8 * 4 + 7 : 4 * 3 + 3;
+       if (!noheader)
+               printf("%*.*s:port\tid\tnfail\t%s\n", wide, wide,
+                   "address", remain ? "remaining time" : "last access");
        for (i = 1; state_iterate(db, &ss, &c, &dbi, i) != 0; i = 0) {
                char buf[BUFSIZ];
                if (!all) {
@@ -123,7 +132,7 @@
                        }
                }
                sockaddr_snprintf(buf, sizeof(buf), "%a", (void *)&ss);
-               printf("%15.15s:%d\t", buf, c.c_port);
+               printf("%*.*s:%d\t", wide, wide, buf, c.c_port);
                if (remain)
                        fmtydhms(buf, sizeof(buf),
                            c.c_duration - (ts.tv_sec - dbi.last));



Home | Main Index | Thread Index | Old Index