From 854adf52322f38a2b82ea33ef375d90a6e6f7daf Mon Sep 17 00:00:00 2001 From: gianluca Date: Mon, 6 Oct 2008 15:27:32 +0000 Subject: Implemented pcap_hopen_offline(). This "internal" function allows us to support pcap_fopen_offline() on windows platforms (where FILE* handles cannot be passed on DLL boundaries). --- savefile.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'savefile.c') diff --git a/savefile.c b/savefile.c index db9ed54..2624e2f 100644 --- a/savefile.c +++ b/savefile.c @@ -30,7 +30,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.177 2008-09-22 20:14:19 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.178 2008-10-06 15:27:32 gianluca Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -1154,6 +1154,33 @@ pcap_open_offline(const char *fname, char *errbuf) return (p); } +#ifdef WIN32 +pcap_t* pcap_hopen_offline(intptr_t osfd, char *errbuf) +{ + int fd; + FILE *file; + + fd = _open_osfhandle(osfd, _O_RDONLY); + if ( fd < 0 ) + { + snprintf(errbuf, PCAP_ERRBUF_SIZE, pcap_strerror(errno)); + return NULL; + } + + file = _fdopen(fd, "rb"); + if ( file == NULL ) + { + snprintf(errbuf, PCAP_ERRBUF_SIZE, pcap_strerror(errno)); + return NULL; + } + + return pcap_fopen_offline(file, errbuf); +} +#endif + +#ifdef WIN32 +static +#endif pcap_t * pcap_fopen_offline(FILE *fp, char *errbuf) { -- cgit v1.2.3