diff options
author | Giorgos Keramidas <keramida@FreeBSD.org> | 2002-11-26 22:53:14 +0000 |
---|---|---|
committer | Giorgos Keramidas <keramida@FreeBSD.org> | 2002-11-26 22:53:14 +0000 |
commit | 3d2209ae92b6baa8b197d6b6aeeb8bd68ca780e9 (patch) | |
tree | eee7e6fd5332c8c0733ecc793df2de1c160d9ab6 | |
parent | 0108d59df29ce3f67062b7866acc9e2a703541cb (diff) | |
download | src-3d2209ae92b6baa8b197d6b6aeeb8bd68ca780e9.tar.gz src-3d2209ae92b6baa8b197d6b6aeeb8bd68ca780e9.zip |
Align timestamps when -t is used in ipfw and ipfw2.
PR: kern/44843
Approved by: re (jhb)
Notes
Notes:
svn path=/head/; revision=107291
-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 145f2269bbce..e9ea0e10c954 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, " "); } } |