/* Read packet header and data for random access. */ static gboolean visual_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { /* Seek to the packet header */ if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; /* Read the packet. */ if (!visual_read_packet(wth, wth->random_fh, phdr, buf, err, err_info)) { if (*err == 0) *err = WTAP_ERR_SHORT_READ; return FALSE; } return TRUE; }
/* Read the next available packet from the file. This is called in a loop to sequentially read the entire file one time. After the file has been read once, any Future access to the packets is done through seek_read. */ static gboolean visual_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { struct visual_read_info *visual = (struct visual_read_info *)wth->priv; /* Check for the end of the packet data. Note that a check for file EOF will not work because there are index values stored after the last packet's data. */ if (visual->current_pkt > visual->num_pkts) { *err = 0; /* it's just an EOF, not an error */ return FALSE; } visual->current_pkt++; *data_offset = file_tell(wth->fh); return visual_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); }