#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.103 2005-12-13 08:37:23 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.106 2006-02-08 01:38:16 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
time_t Time;
static unsigned b_sec;
static unsigned b_usec;
+ int d_usec;
+ int d_sec;
switch (tflag) {
case 3: /* Microseconds since previous packet */
case 5: /* Microseconds since first packet */
- if (b_sec == 0 && tflag == 5) {
+ if (b_sec == 0) {
/* init timestamp for first packet */
b_usec = tvp->tv_usec;
b_sec = tvp->tv_sec;
}
- int d_usec = tvp->tv_usec - b_usec;
- int d_sec = tvp->tv_sec - b_sec;
+ d_usec = tvp->tv_usec - b_usec;
+ d_sec = tvp->tv_sec - b_sec;
while (d_usec < 0) {
d_usec += 1000000;
}
void
-safeputs(const char *s)
+safeputs(const char *s, int maxlen)
{
- while (*s) {
+ int idx = 0;
+ while (*s && idx < maxlen) {
safeputchar(*s);
+ idx++;
s++;
}
}
if (ch < 0x80 && isprint(ch))
printf("%c", ch);
else
- printf("\\%03o", ch);
+ printf("\\0x%02x ", ch);
}