summaryrefslogtreecommitdiff
path: root/wiretap/mp2t.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-06-16 00:20:00 +0000
committerGuy Harris <guy@alum.mit.edu>2013-06-16 00:20:00 +0000
commit8c9edf12800bc6d68894dc457e7ebaf994429da8 (patch)
treeec6efefbd4e7f8227a7b96661f721ff4ba2986c3 /wiretap/mp2t.c
parent3846abe34d6861c6ee0bba61fcd5baa4d213885c (diff)
downloadwireshark-8c9edf12800bc6d68894dc457e7ebaf994429da8.tar.gz
Have the seek-read routines take a Buffer rather than a guint8 pointer
as the "where to put the packet data" argument. This lets more of the libwiretap code be common between the read and seek-read code paths, and also allows for more flexibility in the "fill in the data" path - we can expand the buffer as needed in both cases. svn path=/trunk/; revision=49949
Diffstat (limited to 'wiretap/mp2t.c')
-rw-r--r--wiretap/mp2t.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/wiretap/mp2t.c b/wiretap/mp2t.c
index 16046b06b3..065a89b615 100644
--- a/wiretap/mp2t.c
+++ b/wiretap/mp2t.c
@@ -88,11 +88,13 @@ mp2t_fill_in_pkthdr(mp2t_filetype_t *mp2t, gint64 offset, struct wtap_pkthdr *ph
}
static gboolean
-mp2t_read_data(guint8 *dest, int length, int *err, gchar **err_info, FILE_T fh)
+mp2t_read_data(Buffer *buf, int length, int *err, gchar **err_info, FILE_T fh)
{
int bytes_read;
- bytes_read = file_read(dest, length, fh);
+ buffer_assure_space(buf, length);
+ errno = WTAP_ERR_CANT_READ;
+ bytes_read = file_read(buffer_start_ptr(buf), length, fh);
if (length != bytes_read) {
*err = file_error(fh, err_info);
/* bytes_read==0 is end of file, not a short read */
@@ -115,8 +117,7 @@ mp2t_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
*data_offset = file_tell(wth->fh);
/* read only the actual mpeg2 ts packet, not including a trailer */
- buffer_assure_space(wth->frame_buffer, MP2T_SIZE);
- if (FALSE == mp2t_read_data(buffer_start_ptr(wth->frame_buffer),
+ if (FALSE == mp2t_read_data(wth->frame_buffer,
MP2T_SIZE, err, err_info, wth->fh))
{
return FALSE;
@@ -135,7 +136,7 @@ mp2t_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
static gboolean
mp2t_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
- guint8 *pd, int length, int *err, gchar **err_info)
+ Buffer *buf, int length, int *err, gchar **err_info)
{
mp2t_filetype_t *mp2t;
@@ -147,7 +148,7 @@ mp2t_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
mp2t_fill_in_pkthdr(mp2t, seek_off, phdr);
- return mp2t_read_data(pd, length, err, err_info, wth->random_fh);
+ return mp2t_read_data(buf, length, err, err_info, wth->random_fh);
}
int