/* The open succeeded. Close whatever capture file we had open,
and fill in the information for this file. */
+ cf_callback_invoke(cf_cb_file_closing, cf);
cf_reset_state(cf);
/* Cleanup all data structures used for dissection. */
free_frame_data_sequence(cf->frames);
cf->frames = NULL;
}
+#ifdef WANT_PACKET_EDITOR
+ if (cf->edited_frames) {
+ g_tree_destroy(cf->edited_frames);
+ cf->edited_frames = NULL;
+ }
+#endif
cf_unselect_packet(cf); /* nothing to select */
cf->first_displayed = 0;
cf->last_displayed = 0;
- /* No frame selected, no field in that frame selected. */
+ /* No frames, no frame selected, no field in that frame selected. */
+ cf->count = 0;
cf->current_frame = 0;
cf->current_row = 0;
cf->finfo_selected = NULL;
*/
size = wtap_file_size(cf->wth, NULL);
- /* Another possibility is that we're reading a compressed file and we've
- * read more (uncompressed) data from the file than exists in the
- * (compressed) file. So check how much data we've actually read.
- *
- * This is inside this "if val > 1.0" check to avoid the lseek() when
- * reading uncompressed files. Testing has (thus far) shown no progress
- * bar weirdness resulting from switching from the data offset (when
- * reading the first part of the file) to the real file position.
- */
- file_pos = wtap_read_so_far(cf->wth, NULL);
-
if (size >= 0)
progbar_val = (gfloat) file_pos / (gfloat) size;
}
g_snprintf(status_str, status_size,
- "%" G_GINT64_MODIFIER "dKB of %" G_GINT64_MODIFIER "dKB",
- file_pos / 1024, size / 1024);
+ "%" G_GINT64_MODIFIER "dKB of %" G_GINT64_MODIFIER "dKB",
+ file_pos / 1024, size / 1024);
return progbar_val;
}
const char *errmsg;
char errmsg_errno[1024+1];
gint64 data_offset;
+ gint64 file_pos;
progdlg_t *volatile progbar = NULL;
gboolean stop_flag;
volatile gint64 size;
while ((wtap_read(cf->wth, &err, &err_info, &data_offset))) {
if (size >= 0) {
count++;
+ file_pos = wtap_read_so_far(cf->wth);
+
/* Create the progress bar if necessary.
* Check whether it should be created or not every MIN_NUMBER_OF_PACKET
*/
if ((progbar == NULL) && !(count % MIN_NUMBER_OF_PACKET)){
- progbar_val = calc_progbar_val(cf, size, data_offset, status_str, sizeof(status_str));
+ progbar_val = calc_progbar_val(cf, size, file_pos, status_str, sizeof(status_str));
if (from_save == FALSE)
progbar = delayed_create_progress_dlg("Loading", name_ptr,
TRUE, &stop_flag, &start_time, progbar_val);
to repaint what's pending, and doing so may involve an "ioctl()"
to see if there's any pending input from an X server, and doing
that for every packet can be costly, especially on a big file. */
- if (data_offset >= progbar_nextstep) {
+ if (file_pos >= progbar_nextstep) {
if (progbar != NULL) {
- progbar_val = calc_progbar_val(cf, size, data_offset, status_str, sizeof(status_str));
+ progbar_val = calc_progbar_val(cf, size, file_pos, status_str, sizeof(status_str));
/* update the packet bar content on the first run or frequently on very large files */
#ifdef HAVE_LIBPCAP
if (progbar_quantum > 500000 || displayed_once == 0) {
/* Get the sum of the seek positions in all of the files. */
file_pos = 0;
for (i = 0; i < in_file_count; i++)
- file_pos += wtap_read_so_far(in_files[i].wth, NULL);
+ file_pos += wtap_read_so_far(in_files[i].wth);
progbar_val = (gfloat) file_pos / (gfloat) f_len;
if (progbar_val > 1.0f) {
/* Some file probably grew while we were reading it.
gchar *err_info;
char errmsg_errno[1024+1];
+#ifdef WANT_PACKET_EDITOR
+ /* if fdata->file_off == -1 it means packet was edited, and we must find data inside edited_frames tree */
+ if (G_UNLIKELY(fdata->file_off == -1)) {
+ const modified_frame_data *frame = (const modified_frame_data *) g_tree_lookup(cf->edited_frames, GINT_TO_POINTER(fdata->num));
+
+ if (!frame) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "fdata->file_off == -1, but can't find modified frame!");
+ return FALSE;
+ }
+
+ *pseudo_header = frame->ph;
+ memcpy(pd, frame->pd, fdata->cap_len);
+ return TRUE;
+ }
+#endif
+
if (!wtap_seek_read(cf->wth, fdata->file_off, pseudo_header, pd,
fdata->cap_len, &err, &err_info)) {
switch (err) {
if (fh == NULL)
return CF_PRINT_OPEN_ERROR; /* attempt to open destination failed */
- write_pdml_preamble(fh);
+ write_pdml_preamble(fh, cf->filename);
if (ferror(fh)) {
fclose(fh);
return CF_PRINT_WRITE_ERROR;
mdata->cf = cf;
/* Iterate through all the nodes looking for matching text */
proto_tree_children_foreach(tree, match_subtree_text, mdata);
- return mdata->frame_matched ? MR_MATCHED : MR_NOTMATCHED;
+ return mdata->frame_matched ? MR_MATCHED : MR_NOTMATCHED;
}
static match_result
}
gboolean
-cf_goto_top_frame()
+cf_goto_top_frame(void)
{
/* Find and select */
new_packet_list_select_first_row();
}
gboolean
-cf_goto_bottom_frame()
+cf_goto_bottom_frame(void)
{
/* Find and select */
new_packet_list_select_last_row();
* indent-tabs-mode: nil
* End:
*
- * ex: set shiftwidth=2 tabstop=8 expandtab
+ * ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/