aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/tnef.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-06-02 23:23:47 +0000
committerGuy Harris <guy@alum.mit.edu>2013-06-02 23:23:47 +0000
commit761ab822805cc070c5269bf117bd38f65ea1981f (patch)
tree8331039b3b57e0547e34cdbb58876df80b84d323 /wiretap/tnef.c
parentf7f029c255c6364dc2b3c320ec579a1d9ae747ca (diff)
Pull the code to Fill in the wtap_pkthdr structure into a common
routine, and use it in both the read and seek-read routines. svn path=/trunk/; revision=49702
Diffstat (limited to 'wiretap/tnef.c')
-rw-r--r--wiretap/tnef.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/wiretap/tnef.c b/wiretap/tnef.c
index 3afd1d49d6..f2c34703c8 100644
--- a/wiretap/tnef.c
+++ b/wiretap/tnef.c
@@ -32,6 +32,16 @@
#include "buffer.h"
#include "tnef.h"
+static void tnef_set_pkthdr(struct wtap_pkthdr *phdr, int packet_size)
+{
+ phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */
+
+ phdr->caplen = packet_size;
+ phdr->len = packet_size;
+
+ phdr->ts.secs = 0;
+ phdr->ts.nsecs = 0;
+}
static gboolean tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
@@ -65,24 +75,18 @@ static gboolean tnef_read(wtap *wth, int *err, gchar **err_info, gint64 *data_of
}
packet_size = (int)file_size;
+ tnef_set_pkthdr(&wth->phdr, packet_size);
+
buffer_assure_space(wth->frame_buffer, packet_size);
buf = buffer_start_ptr(wth->frame_buffer);
wtap_file_read_expected_bytes(buf, packet_size, wth->fh, err, err_info);
- wth->phdr.presence_flags = 0; /* no time stamp, no "real length" */
-
- wth->phdr.caplen = packet_size;
- wth->phdr.len = packet_size;
-
- wth->phdr.ts.secs = 0;
- wth->phdr.ts.nsecs = 0;
-
return TRUE;
}
static gboolean tnef_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr _U_,
+ struct wtap_pkthdr *phdr,
guint8 *pd, int length, int *err, gchar **err_info)
{
int packet_size = length;
@@ -96,6 +100,8 @@ static gboolean tnef_seek_read(wtap *wth, gint64 seek_off,
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
+ tnef_set_pkthdr(phdr, packet_size);
+
wtap_file_read_expected_bytes(pd, packet_size, wth->random_fh, err, err_info);
return TRUE;
@@ -109,9 +115,7 @@ int tnef_open(wtap *wth, int *err, gchar **err_info)
bytes_read = file_read(&magic, sizeof magic, wth->fh);
if (bytes_read != sizeof magic) {
*err = file_error(wth->fh, err_info);
- if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1;
- return 0;
+ return (*err != 0) ? -1 : 0;
}
if (htolel(magic) != TNEF_SIGNATURE)