AttachConsole() needs _WIN32_WINNT 0x0500.
[obnox/wireshark/wip.git] / proto_hier_stats.c
index edbad8c265cfc2f1ec04782a1f3fe3fab61aedbc..420e725e702167249c242c9db221a3a223557777 100644 (file)
 # include "config.h"
 #endif
 
+#include <stdio.h>
+
 #include "globals.h"
 #include "proto_hier_stats.h"
 #include "progress_dlg.h"
-#include "simple_dialog.h"
 #include <epan/epan_dissect.h>
 #include <wtap.h>
 
@@ -86,7 +87,8 @@ process_node(proto_node *ptree_node, GNode *parent_stat_node, ph_stats_t *ps, gu
        GNode                   *stat_node;
 
        finfo = PNODE_FINFO(ptree_node);
-       g_assert(finfo);
+       /* We don't fake protocol nodes we expect them to have a field_info */
+       g_assert(finfo && "dissection with faked proto tree?");
 
        /* If the field info isn't related to a protocol but to a field,
         * don't count them, as they don't belong to any protocol.
@@ -141,17 +143,11 @@ process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps)
        epan_dissect_t                  edt;
        union wtap_pseudo_header        phdr;
        guint8                          pd[WTAP_MAX_PACKET_SIZE];
-       int                             err;
-       gchar                           *err_info;
        double                          cur_time;
 
        /* Load the frame from the capture file */
-       if (!wtap_seek_read(cfile.wth, frame->file_off, &phdr, pd,
-           frame->cap_len, &err, &err_info)) {
-               simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
-                   cf_read_error_message(err, err_info), cfile.filename);
+       if (!cf_read_frame_r(&cfile, frame, &phdr, pd))
                return FALSE;   /* failure */
-       }
 
        /* Dissect the frame   tree  not visible */
        epan_dissect_init(&edt, TRUE, FALSE);
@@ -181,6 +177,7 @@ ph_stats_t*
 ph_stats_new(void)
 {
        ph_stats_t      *ps;
+       guint32         framenum;
        frame_data      *frame;
        guint           tot_packets, tot_bytes;
        progdlg_t       *progbar = NULL;
@@ -216,7 +213,9 @@ ph_stats_new(void)
        tot_packets = 0;
        tot_bytes = 0;
 
-       for (frame = cfile.plist; frame != NULL; frame = frame->next) {
+       for (framenum = 1; framenum <= cfile.count; framenum++) {
+               frame = frame_data_sequence_find(cfile.frames, framenum);
+
                /* Create the progress bar if necessary.
                   We check on every iteration of the loop, so that
                   it takes no longer than the standard time to create
@@ -225,7 +224,7 @@ ph_stats_new(void)
                   to get to the next progress bar step). */
                if (progbar == NULL)
                        progbar = delayed_create_progress_dlg(
-                           "Computing", "protocol hierarchy statistics", 
+                           "Computing", "protocol hierarchy statistics",
                            TRUE, &stop_flag, &start_time, progbar_val);
 
                /* Update the progress bar, but do it only N_PROGBAR_UPDATES
@@ -269,7 +268,7 @@ ph_stats_new(void)
                                ps->first_time = cur_time;
                                ps->last_time = cur_time;
                        }
-                       
+
                        /* we don't care about colinfo */
                        if (!process_frame(frame, NULL, ps)) {
                                /*
@@ -312,7 +311,7 @@ ph_stats_new(void)
 static gboolean
 stat_node_free(GNode *node, gpointer data _U_)
 {
-       ph_stats_node_t *stats = node->data;
+       ph_stats_node_t *stats = (ph_stats_node_t *)node->data;
 
        if (stats) {
                g_free(stats);