aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2010-05-07 21:15:24 +0000
committerGerald Combs <gerald@wireshark.org>2010-05-07 21:15:24 +0000
commit0a209d762ee72caf7961cc09675cb3e1f70c1759 (patch)
treef908304a6713e9714f52cc88fc826a04d6f5d98e /wiretap
parent52cbbd605fbe3233ca4ed184ff73d2c3eeb0683a (diff)
Zlib has an officially-sanctioned way of clearing EOF when we're tailing
a file. Use it. svn path=/trunk/; revision=32716
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/wtap.c17
-rw-r--r--wiretap/wtap.h9
2 files changed, 17 insertions, 9 deletions
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index f3a12b1432..f1281a7cf7 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -637,6 +637,15 @@ wtap_close(wtap *wth)
g_free(wth);
}
+void
+wtap_cleareof(wtap *wth) {
+#ifdef HAVE_LIBZ
+ /* Reset EOF */
+ if (gzeof(wth->fh))
+ gzclearerr(wth->fh);
+#endif
+}
+
gboolean
wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
@@ -650,14 +659,6 @@ wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
*/
wth->phdr.pkt_encap = wth->file_encap;
-#if defined(ZLIB_VERNUM) && ZLIB_VERNUM == 0x1250
- /* Reset EOF */
- /* g_log(NULL, G_LOG_LEVEL_DEBUG, "wtap_read: eof before seek: %d", gzeof(wth->fh)); */
- if (gzeof(wth->fh))
- gzseek(wth->fh, 0, SEEK_CUR);
- /* g_log(NULL, G_LOG_LEVEL_DEBUG, "wtap_read: eof after seek: %d", gzeof(wth->fh)); */
-#endif
-
if (!wth->subtype_read(wth, err, err_info, data_offset))
return FALSE; /* failure */
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 5995d97e94..09fae00340 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -886,7 +886,7 @@ struct gsm_um_phdr {
#define GSM_UM_CHANNEL_RACH 6
#define GSM_UM_CHANNEL_AGCH 7
#define GSM_UM_CHANNEL_PCH 8
-
+
union wtap_pseudo_header {
struct eth_phdr eth;
struct x25_phdr x25;
@@ -972,6 +972,13 @@ typedef int (*wtap_open_routine_t)(struct wtap*, int *, char **);
struct wtap* wtap_open_offline(const char *filename, int *err,
gchar **err_info, gboolean do_random);
+/*
+ * If we were compiled with zlib and we're at EOF, unset EOF so that
+ * wtap_read/gzread has a chance to succeed. This is necessary if
+ * we're tailing a file.
+ */
+void wtap_cleareof(wtap *wth);
+
/* Returns TRUE if read was successful. FALSE if failure. data_offset is
* set to the offset in the file where the data for the read packet is
* located. */