Date: Mon, 4 Nov 2002 07:20:03 -0800 (PST) From: Giorgos Keramidas <keramida@freebsd.org> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/44843: ipfw -t l doesn't align columns quite right Message-ID: <200211041520.gA4FK3Xe041875@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: Giorgos Keramidas <keramida@freebsd.org>
To: Chris Pepper <pepper@reppep.com>
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 17:17:54 +0200
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, " ");
}
}
%%%
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?200211041520.gA4FK3Xe041875>
