]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Make "tflag" count the number of "-t"s, to make it more obvious what
authorguy <guy>
Tue, 15 Jun 2004 23:05:05 +0000 (23:05 +0000)
committerguy <guy>
Tue, 15 Jun 2004 23:05:05 +0000 (23:05 +0000)
tflag values correspond to what output formats (e.g., 4 means "-tttt").

Switch on the tflag value to determine whether to call "gmt2local()" to
set "thiszone", just as we switch on it to determine the format for time
stamps, to make it more obvious in what cases we call it.

tcpdump.c
util.c

index 04f0979ded79d22406c93c9d629b2c3dcb387d11..072496547fda30716e7cfe8867185bcda0b961f6 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -30,7 +30,7 @@ static const char copyright[] _U_ =
     "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
 The Regents of the University of California.  All rights reserved.\n";
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.243 2004-06-15 00:00:04 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.244 2004-06-15 23:05:05 guy Exp $ (LBL)";
 #endif
 
 /*
@@ -420,7 +420,6 @@ main(int argc, char **argv)
 
         gndo->ndo_Oflag=1;
        gndo->ndo_Rflag=1;
-       gndo->ndo_tflag=1;
        gndo->ndo_dlt=-1;
        gndo->ndo_printf=tcpdump_printf;
        gndo->ndo_error=ndo_error;
@@ -644,7 +643,7 @@ main(int argc, char **argv)
                        break;
 
                case 't':
-                       --tflag;
+                       ++tflag;
                        break;
 
                case 'T':
@@ -741,8 +740,13 @@ main(int argc, char **argv)
                        /* NOTREACHED */
                }
 
-       if (tflag > 0 || tflag == -3)
+       switch (tflag) {
+
+       case 0: /* Default */
+       case 4: /* Default + Date*/
                thiszone = gmt2local(0);
+               break;
+       }
 
 #ifdef WITH_CHROOT
        /* if run as root, prepare for chrooting */
diff --git a/util.c b/util.c
index 06820a353d1bf807ed34fcce56a0b038cece37e8..97d352720e407cc1da965f16bd1c7f80a8a52761 100644 (file)
--- a/util.c
+++ b/util.c
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.93 2004-04-29 02:15:16 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.94 2004-06-15 23:05:06 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -116,19 +116,25 @@ ts_print(register const struct timeval *tvp)
        static unsigned b_sec;
        static unsigned b_usec;
 
-       switch(tflag) {
-       case 1: /* Default */
+       switch (tflag) {
+
+       case 0: /* Default */
                s = (tvp->tv_sec + thiszone) % 86400;
                (void)printf("%02d:%02d:%02d.%06u ",
                             s / 3600, (s % 3600) / 60, s % 60,
                             (unsigned)tvp->tv_usec);
                break;
-       case -1: /* Unix timeval style */
+
+       case 1: /* No time stamp */
+               break;
+
+       case 2: /* Unix timeval style */
                (void)printf("%u.%06u ",
                             (unsigned)tvp->tv_sec,
                             (unsigned)tvp->tv_usec);
                break;
-       case -2:
+
+       case 3: /* Microseconds since previous packet */
                if (b_sec == 0) {
                        printf("000000 ");
                } else {
@@ -146,7 +152,8 @@ ts_print(register const struct timeval *tvp)
                b_sec = tvp->tv_sec;
                b_usec = tvp->tv_usec;
                break;
-       case -3: /* Default + Date*/
+
+       case 4: /* Default + Date*/
                s = (tvp->tv_sec + thiszone) % 86400;
                Time = (tvp->tv_sec + thiszone) - s;
                tm = gmtime (&Time);