X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/66b89d8fb86a633944c17c380fbd324253f360ba..228b3a827ebc1bc3eb13195e231687d9743b4eca:/util.c diff --git a/util.c b/util.c index 36b8611c..06820a35 100644 --- a/util.c +++ b/util.c @@ -20,8 +20,8 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.86 2003-07-30 00:20:28 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.93 2004-04-29 02:15:16 mcr Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -199,27 +199,9 @@ relts_print(int secs) */ int -print_unknown_data(const u_char *cp,const char *lf,int len) +print_unknown_data(const u_char *cp,const char *ident,int len) { - int i; - - if (len ==0) - return(0); - - printf("%s0x0000: ",lf); - for(i=0;is != NULL) { if (lp->v == v) return (lp->s); @@ -239,8 +219,25 @@ tok2str(register const struct tok *lp, register const char *fmt, } if (fmt == NULL) fmt = "#%d"; - (void)snprintf(buf, sizeof(buf), fmt, v); - return (buf); + + (void)snprintf(buf, bufsize, fmt, v); + return (const char *)buf; +} + +/* + * Convert a token value to a string; use "fmt" if not found. + */ +const char * +tok2str(register const struct tok *lp, register const char *fmt, + register int v) +{ + static char buf[4][128]; + static int idx = 0; + char *ret; + + ret = buf[idx]; + idx = (idx+1) & 3; + return tok2strbuf(lp, fmt, v, ret, sizeof(buf[0])); } /* @@ -249,7 +246,7 @@ tok2str(register const struct tok *lp, register const char *fmt, */ char * bittok2str(register const struct tok *lp, register const char *fmt, - register int v) + register int v) { static char buf[256]; /* our stringbuffer */ int buflen=0;