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/commview.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/commview.c')
-rw-r--r-- | wiretap/commview.c | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/wiretap/commview.c b/wiretap/commview.c index 91697fb0f7..9dc93c522e 100644 --- a/wiretap/commview.c +++ b/wiretap/commview.c @@ -84,7 +84,7 @@ static gboolean commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); static gboolean commview_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, - guint8 *pd, int length, int *err, + Buffer *buf, int length, int *err, gchar **err_info); static gboolean commview_read_header(commview_header_t *cv_hdr, FILE_T fh, int *err, gchar **err_info); @@ -188,22 +188,6 @@ commview_read_and_process_header(FILE_T fh, struct wtap_pkthdr *phdr, } static gboolean -commview_read_record_data(FILE_T fh, guint8 *buf, guint len, int *err, - gchar **err_info) -{ - int bytes_read; - - bytes_read = file_read(buf, len, fh); - if(bytes_read != (int)len) { - *err = file_error(fh, err_info); - if(*err == 0) - *err = WTAP_ERR_SHORT_READ; - return FALSE; - } - return TRUE; -} - -static gboolean commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { *data_offset = file_tell(wth->fh); @@ -212,17 +196,13 @@ commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) err_info)) return FALSE; - buffer_assure_space(wth->frame_buffer, wth->phdr.caplen); - if(!commview_read_record_data(wth->fh, buffer_start_ptr(wth->frame_buffer), - wth->phdr.caplen, err, err_info)) - return FALSE; - - return TRUE; + return wtap_read_packet_bytes(wth->fh, wth->frame_buffer, + wth->phdr.caplen, err, err_info); } static gboolean commview_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) { if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; @@ -240,11 +220,8 @@ commview_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, return FALSE; } - if(!commview_read_record_data(wth->random_fh, pd, phdr->caplen, - err, err_info)) - return FALSE; - - return TRUE; + return wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, + err, err_info); } static gboolean |