tcpdump mailing list archives

Re: savefile.c patch


From: "Gisle Vanem" <giva () bgnett no>
Date: Wed, 26 May 2004 23:16:21 +0200

"Guy Harris" <guy () alum mit edu> said:

Also, is "setmode()" sufficient with all the compilers that could be 
used to compile libpcap/WinPcap on Windows (MSVC++, MinGW, etc.), or is 
"_setmode()" needed with some compilers?  (The code currently uses 
"_setmode()".)

MSVC/MingW/CygWin have both, Watcom has only setmode(). 
_setmode() is just the same ('_' prefixed since it's non-ANSI I assume).

-#ifndef WIN32
- fp = fopen(fname, "r");
-#else
 fp = fopen(fname, "rb");
-#endif

Presumably there are no interesting UN*X platforms left that wouldn't 
ignore the "b" (Ethereal's library for reading capture files 
unconditionally uses "rb"), so that should be OK.

Think that's safe to assume.
 
- if (f == NULL) {
+ setbuf(f, NULL); /* XXX - why? */
+ }

I'm not sure why we're setting the output unbuffered on Windows; even 
if there's a legitimate reason to do so, I don't see any reason to do 
so on UN*X - we really don't want to have the standard I/O library 
routines make a separate "write()" call for every "fwrite()" etc. call 
to the file.

I wasn't sure why either. Maybe reducing the chance of a file with
truncated packets. I just moved setbuf() further up.

--gv

-
This is the tcpdump-workers list.
Visit https://lists.sandelman.ca/ to unsubscribe.


Current thread: