diff options
author | Guy Harris <guy@alum.mit.edu> | 2013-06-16 00:20:00 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2013-06-16 00:20:00 +0000 |
commit | 8c9edf12800bc6d68894dc457e7ebaf994429da8 (patch) | |
tree | ec6efefbd4e7f8227a7b96661f721ff4ba2986c3 /wiretap/mpeg.c | |
parent | 3846abe34d6861c6ee0bba61fcd5baa4d213885c (diff) |
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/mpeg.c')
-rw-r--r-- | wiretap/mpeg.c | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/wiretap/mpeg.c b/wiretap/mpeg.c index 17db40ba8a..f8d1abc632 100644 --- a/wiretap/mpeg.c +++ b/wiretap/mpeg.c @@ -91,24 +91,6 @@ mpeg_read_header(wtap *wth, int *err, gchar **err_info, guint32 *n) return bytes_read; } -static gboolean -mpeg_read_rec_data(FILE_T fh, guint8 *pd, int length, int *err, - gchar **err_info) -{ - int bytes_read; - - errno = WTAP_ERR_CANT_READ; - bytes_read = file_read(pd, length, fh); - - if (bytes_read != length) { - *err = file_error(fh, err_info); - if (*err == 0) - *err = WTAP_ERR_SHORT_READ; - return FALSE; - } - return TRUE; -} - #define SCRHZ 27000000 static gboolean @@ -225,8 +207,7 @@ mpeg_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) } *data_offset = file_tell(wth->fh); - buffer_assure_space(wth->frame_buffer, packet_size); - if (!mpeg_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), + if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer, packet_size, err, err_info)) return FALSE; /* XXX - relative, not absolute, time stamps */ @@ -239,12 +220,12 @@ mpeg_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) static gboolean mpeg_seek_read(wtap *wth, gint64 seek_off, - struct wtap_pkthdr *phdr _U_, guint8 *pd, int length, + struct wtap_pkthdr *phdr _U_, Buffer *buf, int length, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - return mpeg_read_rec_data(wth->random_fh, pd, length, err, err_info); + return wtap_read_packet_bytes(wth->random_fh, buf, length, err, err_info); } struct _mpeg_magic { |