aboutsummaryrefslogtreecommitdiffstats
path: root/savefile.c
diff options
context:
space:
mode:
authorgianluca <gianluca>2008-10-06 15:27:32 +0000
committergianluca <gianluca>2008-10-06 15:27:32 +0000
commit854adf52322f38a2b82ea33ef375d90a6e6f7daf (patch)
tree6e3dd3ca70670fd076909dce7bec532165ecce47 /savefile.c
parentd47aed311c139a33a0a9e79c6b0be32807e1b40e (diff)
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).
Diffstat (limited to 'savefile.c')
-rw-r--r--savefile.c29
1 files changed, 28 insertions, 1 deletions
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)
{