dect
/
libpcap
Archived
13
0
Fork 0

Fixed the definition of SET_BINMODE(): the correct flag under VC6 is

_O_BINARY (which is accepted by Cygwin, as well).

Moved SET_BINMODE while reading from stdin *before* reading the savefile
header.
This commit is contained in:
risso 2005-04-26 00:20:33 +00:00
parent fa82a02ff2
commit faecfbb7de
1 changed files with 12 additions and 11 deletions

View File

@ -30,7 +30,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.126.2.1 2005-04-10 18:04:52 hannes Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.126.2.2 2005-04-26 00:20:33 risso Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -98,7 +98,7 @@ static const char rcsid[] _U_ =
* Setting O_BINARY on DOS/Windows is a bit tricky
*/
#if defined(WIN32)
#define SET_BINMODE(f) _setmode(fileno(f), O_BINARY)
#define SET_BINMODE(f) _setmode(fileno(f), _O_BINARY)
#elif defined(MSDOS)
#if defined(__HIGHC__)
#define SET_BINMODE(f) setmode(f, O_BINARY)
@ -727,7 +727,17 @@ pcap_open_offline(const char *fname, char *errbuf)
pcap_t *p;
if (fname[0] == '-' && fname[1] == '\0')
{
fp = stdin;
#if defined(WIN32) || defined(MSDOS)
/*
* If we're reading from the standard input, put it in binary
* mode, as savefiles are binary files.
*/
SET_BINMODE(fp);
#endif
}
else {
#if !defined(WIN32) && !defined(MSDOS)
fp = fopen(fname, "r");
@ -909,15 +919,6 @@ pcap_fopen_offline(FILE *fp, char *errbuf)
p->stats_op = sf_stats;
p->close_op = sf_close;
#if defined(WIN32) || defined(MSDOS)
/*
* If we're reading from the standard input, put it in binary
* mode, as savefiles are binary files.
*/
if (fp == stdin)
SET_BINMODE(fp);
#endif
return (p);
bad:
free(p);