diff options
author | keramida <keramida@FreeBSD.org> | 2002-11-26 22:53:14 +0000 |
---|---|---|
committer | keramida <keramida@FreeBSD.org> | 2002-11-26 22:53:14 +0000 |
commit | 2dcf3f40e1f30f9d91ee9967b3826786db73333b (patch) | |
tree | eee7e6fd5332c8c0733ecc793df2de1c160d9ab6 /sbin | |
parent | 5305c7ad55add2773de10317f463ed14cb6d4787 (diff) | |
download | FreeBSD-src-2dcf3f40e1f30f9d91ee9967b3826786db73333b.zip FreeBSD-src-2dcf3f40e1f30f9d91ee9967b3826786db73333b.tar.gz |
Align timestamps when -t is used in ipfw and ipfw2.
PR: kern/44843
Approved by: re (jhb)
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ipfw/ipfw2.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c index 145f226..e9ea0e1 100644 --- a/sbin/ipfw/ipfw2.c +++ b/sbin/ipfw/ipfw2.c @@ -804,6 +804,7 @@ show_prerequisites(int *flags, int want, int cmd) static void show_ipfw(struct ip_fw *rule) { + static int twidth = 0; int l; ipfw_insn *cmd; int proto = 0; /* default */ @@ -825,15 +826,22 @@ show_ipfw(struct ip_fw *rule) printf("%10qu %10qu ", rule->pcnt, rule->bcnt); if (do_time) { + char timestr[30]; + time_t t = (time_t)0; + + if (twidth == 0) { + strcpy(timestr, ctime(&t)); + *strchr(timestr, '\n') = '\0'; + twidth = strlen(timestr); + } if (rule->timestamp) { - char timestr[30]; - time_t t = _long_to_time(rule->timestamp); + t = _long_to_time(rule->timestamp); strcpy(timestr, ctime(&t)); *strchr(timestr, '\n') = '\0'; printf("%s ", timestr); } else { - printf(" "); + printf("%*s", twidth, " "); } } |