Date: Mon, 4 Nov 2002 18:40:02 -0800 (PST) From: Chris Pepper <pepper@reppep.com> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/44843: ipfw -t l doesn't align columns quite right Message-ID: <200211050240.gA52e2IU042841@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/44843; it has been noted by GNATS.
From: Chris Pepper <pepper@reppep.com>
To: Giorgos Keramidas <keramida@freebsd.org>
Cc: bug-followup@freebsd.org, Luigi Rizzo <luigi@freebsd.org>
Subject: Re: kern/44843: ipfw -t l doesn't align columns quite right
Date: Mon, 4 Nov 2002 21:28:43 -0500
Looks much better, thanks.
Chris
At 5:17 PM +0200 2002/11/04, Giorgos Keramidas wrote:
>On 2002-11-04 09:26, Chris Pepper <pepper@reppep.com> wrote:
>> Sorry, I'm using ipfw1 -- isn't this for v2?
>
>Err, yes. Sorry 'bout that. I don't have a -STABLE machine right
>now. Does the following work for your ipfw version? I have tested
>that it compiles on ref4.freebsd.org but I don't have access to a
>-stable system to run ipfw and see if it fixes it all. I've tried to
>make changes both to ipfw.c and ipfw2.c since the necessary diffs were
>pretty similar...
>
>%%%
>Index: ipfw.c
>===================================================================
>RCS file: /home/ncvs/src/sbin/ipfw/ipfw.c,v
>retrieving revision 1.80.2.24
>diff -u -r1.80.2.24 ipfw.c
>--- ipfw.c 26 Sep 2002 07:19:05 -0000 1.80.2.24
>+++ ipfw.c 4 Nov 2002 14:52:51 -0000
>@@ -183,6 +183,7 @@
> static void
> show_ipfw(struct ip_fw *chain, int pcwidth, int bcwidth)
> {
>+ static int twidth = 0;
> char comma;
> u_long adrt;
> struct hostent *he;
>@@ -200,14 +201,19 @@
> printf("%*qu %*qu ", pcwidth, chain->fw_pcnt,
>bcwidth, chain->fw_bcnt);
>
> if (do_time) {
>- if (chain->timestamp) {
>- char timestr[30];
>+ char timestr[30];
>
>+ if (twidth == 0) {
>+ strcpy(timestr, ctime((time_t *)&twidth));
>+ *strchr(timestr, '\n') = '\0';
>+ twidth = strlen(timestr);
>+ }
>+ if (chain->timestamp) {
> strcpy(timestr, ctime((time_t *)&chain->timestamp));
> *strchr(timestr, '\n') = '\0';
> printf("%s ", timestr);
> } else {
>- printf(" ");
>+ printf("%*s ", twidth, " ");
> }
> }
> if (chain->fw_flg == IP_FW_F_CHECK_S) {
>Index: ipfw2.c
>===================================================================
>RCS file: /home/ncvs/src/sbin/ipfw/ipfw2.c,v
>retrieving revision 1.4.2.6
>diff -u -r1.4.2.6 ipfw2.c
>--- ipfw2.c 10 Oct 2002 20:46:04 -0000 1.4.2.6
>+++ ipfw2.c 4 Nov 2002 14:57:24 -0000
>@@ -803,6 +803,7 @@
> static void
> show_ipfw(struct ip_fw *rule)
> {
>+ static int twidth = 0;
> int l;
> ipfw_insn *cmd;
> int proto = 0; /* default */
>@@ -824,8 +825,14 @@
> printf("%10qu %10qu ", rule->pcnt, rule->bcnt);
>
> if (do_time) {
>+ char timestr[30];
>+
>+ if (twidth == 0) {
>+ strcpy(timestr, ctime((time_t *)&twidth));
>+ *strchr(timestr, '\n') = '\0';
>+ twidth = strlen(timestr);
>+ }
> if (rule->timestamp) {
>- char timestr[30];
> #if _FreeBSD_version < 500000 /* XXX check */
> #define _long_to_time(x) (time_t)(x)
> #endif
>@@ -835,7 +842,7 @@
> *strchr(timestr, '\n') = '\0';
> printf("%s ", timestr);
> } else {
>- printf(" ");
>+ printf("%*s ", twidth, " ");
> }
> }
>
>%%%
--
Chris Pepper: <http://www.reppep.com/~pepper/>
Rockefeller University: <http://www.rockefeller.edu/>
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200211050240.gA52e2IU042841>
