diff options
author | fenner <fenner@FreeBSD.org> | 1998-09-15 19:36:32 +0000 |
---|---|---|
committer | fenner <fenner@FreeBSD.org> | 1998-09-15 19:36:32 +0000 |
commit | cfc42b58f229425374e675f86614cf26ffa356e4 (patch) | |
tree | 6bd786e664682d3877b9cca3efa525ac67d8e005 /contrib/tcpdump/util.c | |
parent | a9b9c86c8a0ccde5c1480bf5a0ba250d949a6d65 (diff) | |
download | FreeBSD-src-cfc42b58f229425374e675f86614cf26ffa356e4.zip FreeBSD-src-cfc42b58f229425374e675f86614cf26ffa356e4.tar.gz |
Virgin import of LBL tcpdump v3.4
Diffstat (limited to 'contrib/tcpdump/util.c')
-rw-r--r-- | contrib/tcpdump/util.c | 64 |
1 files changed, 5 insertions, 59 deletions
diff --git a/contrib/tcpdump/util.c b/contrib/tcpdump/util.c index 254a64e..6b07200 100644 --- a/contrib/tcpdump/util.c +++ b/contrib/tcpdump/util.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996 + * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: util.c,v 1.55 96/09/26 23:36:51 leres Exp $ (LBL)"; + "@(#) $Header: util.c,v 1.58 97/05/09 14:52:17 leres Exp $ (LBL)"; #endif #include <sys/types.h> @@ -34,6 +34,9 @@ static const char rcsid[] = #ifdef HAVE_FCNTL_H #include <fcntl.h> #endif +#ifdef HAVE_MALLOC_H +#include <malloc.h> +#endif #include <pcap.h> #include <stdio.h> #if __STDC__ @@ -246,31 +249,6 @@ copy_argv(register char **argv) return buf; } -/* A replacement for strdup() that cuts down on malloc() overhead */ -char * -savestr(register const char *str) -{ - register u_int size; - register char *p; - static char *strptr = NULL; - static u_int strsize = 0; - - size = strlen(str) + 1; - if (size > strsize) { - strsize = 1024; - if (strsize < size) - strsize = size; - strptr = (char *)malloc(strsize); - if (strptr == NULL) - error("savestr: malloc"); - } - (void)strcpy(strptr, str); - p = strptr; - strptr += size; - strsize -= size; - return (p); -} - char * read_infile(char *fname) { @@ -295,35 +273,3 @@ read_infile(char *fname) return (cp); } - -/* - * Returns the difference between gmt and local time in seconds. - * Use gmtime() and localtime() to keep things simple. - */ -int32_t -gmt2local(void) -{ - register int dt, dir; - register struct tm *gmt, *loc; - time_t t; - struct tm sgmt; - - t = time(NULL); - gmt = &sgmt; - *gmt = *gmtime(&t); - loc = localtime(&t); - dt = (loc->tm_hour - gmt->tm_hour) * 60 * 60 + - (loc->tm_min - gmt->tm_min) * 60; - - /* - * If the year or julian day is different, we span 00:00 GMT - * and must add or subtract a day. Check the year first to - * avoid problems when the julian day wraps. - */ - dir = loc->tm_year - gmt->tm_year; - if (dir == 0) - dir = loc->tm_yday - gmt->tm_yday; - dt += dir * 24 * 60 * 60; - - return (dt); -} |