aboutsummaryrefslogtreecommitdiff
path: root/sf-pcap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-09-29 14:49:22 -0700
committerGuy Harris <guy@alum.mit.edu>2017-09-29 14:49:22 -0700
commit8bac534951f44d0a3e3e7951c79c95d587fc234b (patch)
treec71e194a12214de9e845690b3f9650bc7a40f238 /sf-pcap.c
parentf00cf656dc7d58d18c26191ed0ae325dccb91031 (diff)
Add pcap_dump_ftell64().
If file offsets are 64-bit, this will return an un-truncated offset.
Diffstat (limited to 'sf-pcap.c')
-rw-r--r--sf-pcap.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/sf-pcap.c b/sf-pcap.c
index 38ddf17a..979b9c41 100644
--- a/sf-pcap.c
+++ b/sf-pcap.c
@@ -1009,6 +1009,45 @@ pcap_dump_ftell(pcap_dumper_t *p)
return (ftell((FILE *)p));
}
+#if defined(HAVE_FSEEKO)
+/*
+ * We have fseeko(), so we have ftello().
+ * If we have large file support (files larger than 2^31-1 bytes),
+ * ftello() will give us a current file position with more than 32
+ * bits.
+ */
+int64_t
+pcap_dump_ftell64(pcap_dumper_t *p)
+{
+ return (ftello((FILE *)p));
+}
+#elif defined(_MSC_VER)
+/*
+ * We have Visual Studio; we support only 2005 and later, so we have
+ * _ftelli64().
+ */
+int64_t
+pcap_dump_ftell64(pcap_dumper_t *p)
+{
+ return (_ftelli64((FILE *)p));
+}
+#else
+/*
+ * We don't have ftello() or _ftelli64(), so fall back on ftell().
+ * Either long is 64 bits, in which case ftell() should suffice,
+ * or this is probably an older 32-bit UN*X without large file
+ * support, which means you'll probably get errors trying to
+ * write files > 2^31-1, so it won't matter anyway.
+ *
+ * XXX - what about MinGW?
+ */
+int64_t
+pcap_dump_ftell64(pcap_dumper_t *p)
+{
+ return (ftell((FILE *)p));
+}
+#endif
+
int
pcap_dump_flush(pcap_dumper_t *p)
{