Clean up indentation.
[obnox/wireshark/wip.git] / gtk / service_response_time_table.c
index 07a1bbe37b10448bccfc9b9817a9b447347c6797..ec66036c257df3acf50e93a89a720b425d1243f5 100644 (file)
@@ -3,7 +3,7 @@
  * Helper routines common to all service response time statistics
  * tap.
  *
- * $Id: service_response_time_table.c,v 1.14 2004/02/06 19:19:11 ulfl Exp $
+ * $Id$
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -45,8 +45,9 @@
 #include "gtk/color_dlg.h"
 #include "main.h"
 #include "ui_util.h"
+#include "gtkglobals.h"
+
 
-extern GtkWidget   *main_display_filter_widget;
 #define GTK_MENU_FUNC(a) ((GtkItemFactoryCallback)(a))
 
 
@@ -105,8 +106,8 @@ srt_sort_column(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
        int i1, i2;
        float f1,f2;
 
-       GtkCListRow *row1 = (GtkCListRow *) ptr1;
-       GtkCListRow *row2 = (GtkCListRow *) ptr2;
+       const GtkCListRow *row1 = ptr1;
+       const GtkCListRow *row2 = ptr2;
 
        text1 = GTK_CELL_TEXT (row1->cell[clist->sort_column])->text;
        text2 = GTK_CELL_TEXT (row2->cell[clist->sort_column])->text;
@@ -183,27 +184,27 @@ srt_select_filter_cb(GtkWidget *widget _U_, gpointer callback_data, guint callba
        switch(type){
        case 0:
                /* selected */
-               snprintf(str, 255, "%s==%d", rst->filter_string, selection);
+               g_snprintf(str, 255, "%s==%d", rst->filter_string, selection);
                break;
        case 1:
                /* not selected */
-               snprintf(str, 255, "!(%s==%d)", rst->filter_string, selection);
+               g_snprintf(str, 255, "!(%s==%d)", rst->filter_string, selection);
                break;
        case 2:
                /* and selected */
-               snprintf(str, 255, "(%s) && (%s==%d)", current_filter, rst->filter_string, selection);
+               g_snprintf(str, 255, "(%s) && (%s==%d)", current_filter, rst->filter_string, selection);
                break;
        case 3:
                /* or selected */
-               snprintf(str, 255, "(%s) || (%s==%d)", current_filter, rst->filter_string, selection);
+               g_snprintf(str, 255, "(%s) || (%s==%d)", current_filter, rst->filter_string, selection);
                break;
        case 4:
                /* and not selected */
-               snprintf(str, 255, "(%s) && !(%s==%d)", current_filter, rst->filter_string, selection);
+               g_snprintf(str, 255, "(%s) && !(%s==%d)", current_filter, rst->filter_string, selection);
                break;
        case 5:
                /* or not selected */
-               snprintf(str, 255, "(%s) || !(%s==%d)", current_filter, rst->filter_string, selection);
+               g_snprintf(str, 255, "(%s) || !(%s==%d)", current_filter, rst->filter_string, selection);
                break;
        }
 
@@ -212,7 +213,7 @@ srt_select_filter_cb(GtkWidget *widget _U_, gpointer callback_data, guint callba
        switch(action){
        case 0:
                /* match */
-               main_filter_packets(&cfile, str);
+               main_filter_packets(&cfile, str, FALSE);
        case 1:
                /* prepare */
                /* do nothing */
@@ -253,33 +254,33 @@ srt_show_popup_menu_cb(void *widg _U_, GdkEvent *event, srt_stat_table *rst)
 static GtkItemFactoryEntry srt_list_menu_items[] =
 {
        /* Match */
-       ITEM_FACTORY_ENTRY("/Match Display Filter", NULL, NULL, 0, "<Branch>", NULL),
-       ITEM_FACTORY_ENTRY("/Match Display Filter/Selected", NULL,
+       ITEM_FACTORY_ENTRY("/Apply as Filter", NULL, NULL, 0, "<Branch>", NULL),
+       ITEM_FACTORY_ENTRY("/Apply as Filter/Selected", NULL,
                srt_select_filter_cb, 0*256+0, NULL, NULL),
-       ITEM_FACTORY_ENTRY("/Match Display Filter/Not Selected", NULL,
+       ITEM_FACTORY_ENTRY("/Apply as Filter/... not Selected", NULL,
                srt_select_filter_cb, 0*256+1, NULL, NULL),
-       ITEM_FACTORY_ENTRY("/Match Display Filter/And Selected", NULL,
+       ITEM_FACTORY_ENTRY("/Apply as Filter/.. and Selected", NULL,
                srt_select_filter_cb, 0*256+2, NULL, NULL),
-       ITEM_FACTORY_ENTRY("/Match Display Filter/Or Selected", NULL,
+       ITEM_FACTORY_ENTRY("/Apply as Filter/... or Selected", NULL,
                srt_select_filter_cb, 0*256+3, NULL, NULL),
-       ITEM_FACTORY_ENTRY("/Match Display Filter/And Not Selected", NULL,
+       ITEM_FACTORY_ENTRY("/Apply as Filter/... and not Selected", NULL,
                srt_select_filter_cb, 0*256+4, NULL, NULL),
-       ITEM_FACTORY_ENTRY("/Match Display Filter/Or Not Selected", NULL,
+       ITEM_FACTORY_ENTRY("/Apply as Filter/... or not Selected", NULL,
                srt_select_filter_cb, 0*256+5, NULL, NULL),
 
        /* Prepare */
-       ITEM_FACTORY_ENTRY("/Prepare Display Filter", NULL, NULL, 0, "<Branch>", NULL),
-       ITEM_FACTORY_ENTRY("/Prepare Display Filter/Selected", NULL,
+       ITEM_FACTORY_ENTRY("/Prepare a Filter", NULL, NULL, 0, "<Branch>", NULL),
+       ITEM_FACTORY_ENTRY("/Prepare a Filter/Selected", NULL,
                srt_select_filter_cb, 1*256+0, NULL, NULL),
-       ITEM_FACTORY_ENTRY("/Prepare Display Filter/Not Selected", NULL,
+       ITEM_FACTORY_ENTRY("/Prepare a Filter/Not Selected", NULL,
                srt_select_filter_cb, 1*256+1, NULL, NULL),
-       ITEM_FACTORY_ENTRY("/Prepare Display Filter/And Selected", NULL,
+       ITEM_FACTORY_ENTRY("/Prepare a Filter/... and Selected", NULL,
                srt_select_filter_cb, 1*256+2, NULL, NULL),
-       ITEM_FACTORY_ENTRY("/Prepare Display Filter/Or Selected", NULL,
+       ITEM_FACTORY_ENTRY("/Prepare a Filter/... or Selected", NULL,
                srt_select_filter_cb, 1*256+3, NULL, NULL),
-       ITEM_FACTORY_ENTRY("/Prepare Display Filter/And Not Selected", NULL,
+       ITEM_FACTORY_ENTRY("/Prepare a Filter/... and not Selected", NULL,
                srt_select_filter_cb, 1*256+4, NULL, NULL),
-       ITEM_FACTORY_ENTRY("/Prepare Display Filter/Or Not Selected", NULL,
+       ITEM_FACTORY_ENTRY("/Prepare a Filter/... or not Selected", NULL,
                srt_select_filter_cb, 1*256+5, NULL, NULL),
 
        /* Find Frame */
@@ -430,8 +431,26 @@ init_srt_table_row(srt_stat_table *rst, int index, char *procedure)
 {
        char str[10];
 
-
-       sprintf(str,"%d",index);
+       /* we have discovered a new procedure. Extend the table accordingly */
+       if(index>=rst->num_procs){
+               int old_num_procs=rst->num_procs;
+               int i,j;
+               rst->num_procs=index+1;
+               rst->procedures=g_realloc(rst->procedures, sizeof(srt_procedure_t)*(rst->num_procs));
+               for(i=old_num_procs;i<rst->num_procs;i++){
+                       rst->procedures[i].num=0;
+                       rst->procedures[i].min.secs=0;
+                       rst->procedures[i].min.nsecs=0;
+                       rst->procedures[i].max.secs=0;
+                       rst->procedures[i].max.nsecs=0;
+                       rst->procedures[i].tot.secs=0;
+                       rst->procedures[i].tot.nsecs=0;
+                       for(j=0;j<6;j++){
+                               rst->procedures[i].entries[j]=NULL;
+                       }
+               }
+       }
+       g_snprintf(str, 10, "%d",index);
        rst->procedures[index].entries[0]=g_strdup(str);
 
        rst->procedures[index].entries[1]=g_strdup(procedure);
@@ -446,7 +465,7 @@ init_srt_table_row(srt_stat_table *rst, int index, char *procedure)
 }
 
 void
-add_srt_table_data(srt_stat_table *rst, int index, nstime_t *req_time, packet_info *pinfo)
+add_srt_table_data(srt_stat_table *rst, int index, const nstime_t *req_time, packet_info *pinfo)
 {
        srt_procedure_t *rp;
        nstime_t delta;
@@ -518,27 +537,27 @@ draw_srt_table_data(srt_stat_table *rst)
                }
 
                j=gtk_clist_find_row_from_data(rst->table, (gpointer)i);
-               sprintf(str,"%d", rst->procedures[i].num);
+               g_snprintf(str, 256, "%d", rst->procedures[i].num);
                strp=g_strdup(str);
                gtk_clist_set_text(rst->table, j, 2, strp);
                g_free(rst->procedures[i].entries[2]);
                rst->procedures[i].entries[2]=strp;
 
 
-               sprintf(str,"%3d.%05d", (int)rst->procedures[i].min.secs,rst->procedures[i].min.nsecs/10000);
+               g_snprintf(str, 256, "%3d.%05d", (int)rst->procedures[i].min.secs,rst->procedures[i].min.nsecs/10000);
                strp=g_strdup(str);
                gtk_clist_set_text(rst->table, j, 3, strp);
                g_free(rst->procedures[i].entries[3]);
                rst->procedures[i].entries[3]=strp;
 
 
-               sprintf(str,"%3d.%05d", (int)rst->procedures[i].max.secs,rst->procedures[i].max.nsecs/10000);
+               g_snprintf(str, 256, "%3d.%05d", (int)rst->procedures[i].max.secs,rst->procedures[i].max.nsecs/10000);
                strp=g_strdup(str);
                gtk_clist_set_text(rst->table, j, 4, strp);
                g_free(rst->procedures[i].entries[4]);
                rst->procedures[i].entries[4]=strp;
 
-               sprintf(str,"%3d.%05d", td/100000, td%100000);
+               g_snprintf(str, 256, "%3d.%05d", td/100000, td%100000);
                strp=g_strdup(str);
                gtk_clist_set_text(rst->table, j, 5, strp);
                g_free(rst->procedures[i].entries[5]);