update expert info LED also while doing live capturing
[obnox/wireshark/wip.git] / gtk / ansi_a_stat.c
index 4f78e3e754a242f85bde7fbc40f74006aa5dcfc8..927970a4a990f3585793e6b2a9df0e000440a590 100644 (file)
@@ -7,8 +7,8 @@
  *
  * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
  * This program is free software; you can redistribute it and/or
@@ -40,7 +40,9 @@
 #include "epan/packet_info.h"
 #include "epan/epan.h"
 #include "epan/value_string.h"
-#include "tap_menu.h"
+#include <epan/stat_cmd_args.h>
+#include "../stat_menu.h"
+#include "gui_stat_menu.h"
 #include "image/clist_ascend.xpm"
 #include "image/clist_descend.xpm"
 #include "simple_dialog.h"
@@ -52,7 +54,7 @@
 #include "../globals.h"
 #include "filter_dlg.h"
 #include "compat_macros.h"
-#include "ui_util.h"
+#include "gui_utils.h"
 
 
 typedef struct column_arrows {
@@ -76,7 +78,7 @@ typedef struct _ansi_a_stat_t {
 
 static ansi_a_stat_dlg_t       dlg_bsmap;
 static ansi_a_stat_dlg_t       dlg_dtap;
-static ansi_a_stat_t           stat;
+static ansi_a_stat_t           ansi_a_stat;
 
 
 static void
@@ -128,16 +130,16 @@ ansi_a_stat_draw(
     int                        i, j;
     char               *strp;
 
-    if (dlg_bsmap.win != NULL)
+    if (dlg_bsmap.win && tapdata)
     {
        i = 0;
 
-       while (ansi_a_ios401_bsmap_strings[i].strptr)
+       while (ansi_a_bsmap_strings[i].strptr)
        {
-           j = gtk_clist_find_row_from_data(GTK_CLIST(dlg_bsmap.table), (gpointer) i);
+           j = gtk_clist_find_row_from_data(GTK_CLIST(dlg_bsmap.table), (gpointer)(long) i);
 
            strp = g_strdup_printf("%d",
-                   stat_p->bsmap_message_type[ansi_a_ios401_bsmap_strings[i].value]);
+                   stat_p->bsmap_message_type[ansi_a_bsmap_strings[i].value]);
            gtk_clist_set_text(GTK_CLIST(dlg_bsmap.table), j, 2, strp);
            g_free(strp);
 
@@ -147,16 +149,16 @@ ansi_a_stat_draw(
        gtk_clist_sort(GTK_CLIST(dlg_bsmap.table));
     }
 
-    if (dlg_dtap.win != NULL)
+    if (dlg_dtap.win && tapdata)
     {
        i = 0;
 
-       while (ansi_a_ios401_dtap_strings[i].strptr)
+       while (ansi_a_dtap_strings[i].strptr)
        {
-           j = gtk_clist_find_row_from_data(GTK_CLIST(dlg_dtap.table), (gpointer) i);
+           j = gtk_clist_find_row_from_data(GTK_CLIST(dlg_dtap.table), (gpointer)(long) i);
 
            strp = g_strdup_printf("%d",
-                   stat_p->dtap_message_type[ansi_a_ios401_dtap_strings[i].value]);
+                   stat_p->dtap_message_type[ansi_a_dtap_strings[i].value]);
            gtk_clist_set_text(GTK_CLIST(dlg_dtap.table), j, 2, strp);
            g_free(strp);
 
@@ -271,10 +273,10 @@ ansi_a_stat_gtk_win_destroy_cb(
 static void
 ansi_a_stat_gtk_win_create(
     ansi_a_stat_dlg_t  *dlg_p,
-    char               *title)
+    const char         *title)
 {
 #define        INIT_TABLE_NUM_COLUMNS  3
-    char               *default_titles[] = { "IEI", "Message Name", "Count" };
+    const char         *default_titles[] = { "IEI", "Message Name", "Count" };
     int                        i;
     column_arrows      *col_arrows;
     GtkWidget          *column_lb;
@@ -286,9 +288,9 @@ ansi_a_stat_gtk_win_create(
     dlg_p->win = window_new(GTK_WINDOW_TOPLEVEL, title);
     gtk_window_set_default_size(GTK_WINDOW(dlg_p->win), 480, 450);
 
-       vbox=gtk_vbox_new(FALSE, 3);
-       gtk_container_add(GTK_CONTAINER(dlg_p->win), vbox);
-       gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
+    vbox=gtk_vbox_new(FALSE, 3);
+    gtk_container_add(GTK_CONTAINER(dlg_p->win), vbox);
+    gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
 
     dlg_p->scrolled_win = scrolled_window_new(NULL, NULL);
     gtk_box_pack_start(GTK_BOX(vbox), dlg_p->scrolled_win, TRUE, TRUE, 0);
@@ -307,19 +309,19 @@ ansi_a_stat_gtk_win_create(
         column_lb = gtk_label_new(default_titles[i]);
 
         gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb,
-        0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
+           0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
 
         gtk_widget_show(column_lb);
 
         col_arrows[i].ascend_pm = xpm_to_widget(clist_ascend_xpm);
 
         gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].ascend_pm,
-        1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
+           1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
 
         col_arrows[i].descend_pm = xpm_to_widget(clist_descend_xpm);
 
         gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].descend_pm,
-        1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
+           1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
 
         if (i == 0)
         {
@@ -348,7 +350,7 @@ ansi_a_stat_gtk_win_create(
 
        /* Button row. */
     bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
-       gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
 
     bt_close = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
     window_set_cancel_button(dlg_p->win, bt_close, window_cancel_button_cb);
@@ -361,26 +363,12 @@ ansi_a_stat_gtk_win_create(
 }
 
 
-/*
- * Never gets called ?
- */
-static void
-ansi_a_stat_gtk_init(
-    char               *optarg)
-{
-    /* does not appear to be called */
-
-    optarg = optarg;
-}
-
-
 static void
 ansi_a_stat_gtk_bsmap_cb(
     GtkWidget          *w _U_,
     gpointer           d _U_)
 {
     int                        i;
-    char               str[100];
 
 
     /*
@@ -395,22 +383,30 @@ ansi_a_stat_gtk_bsmap_cb(
     ansi_a_stat_gtk_win_create(&dlg_bsmap, "ANSI A-I/F BSMAP Statistics");
 
     i = 0;
-    while (ansi_a_ios401_bsmap_strings[i].strptr)
+    while (ansi_a_bsmap_strings[i].strptr)
     {
-       g_snprintf(str, 100, "0x%02x", ansi_a_ios401_bsmap_strings[i].value);
-       dlg_bsmap.entries[0] = g_strdup(str);
+       dlg_bsmap.entries[0] = g_strdup_printf("0x%02x",
+                                              ansi_a_bsmap_strings[i].value);
 
-       dlg_bsmap.entries[1] = g_strdup(ansi_a_ios401_bsmap_strings[i].strptr);
+       dlg_bsmap.entries[1] = g_strdup(ansi_a_bsmap_strings[i].strptr);
 
        dlg_bsmap.entries[2] = g_strdup("0");
 
        gtk_clist_insert(GTK_CLIST(dlg_bsmap.table), i, dlg_bsmap.entries);
-       gtk_clist_set_row_data(GTK_CLIST(dlg_bsmap.table), i, (gpointer) i);
+       gtk_clist_set_row_data(GTK_CLIST(dlg_bsmap.table), i, (gpointer)(long) i);
 
        i++;
     }
 
-    ansi_a_stat_draw(NULL);
+    ansi_a_stat_draw(&ansi_a_stat);
+}
+
+
+static void
+ansi_a_stat_gtk_bsmap_init(
+    const char         *optarg _U_, void* userdata _U_)
+{
+    ansi_a_stat_gtk_bsmap_cb(NULL, NULL);
 }
 
 
@@ -420,7 +416,6 @@ ansi_a_stat_gtk_dtap_cb(
     gpointer           d _U_)
 {
     int                        i;
-    char               str[100];
 
 
     /*
@@ -435,22 +430,31 @@ ansi_a_stat_gtk_dtap_cb(
     ansi_a_stat_gtk_win_create(&dlg_dtap, "ANSI A-I/F DTAP Statistics");
 
     i = 0;
-    while (ansi_a_ios401_dtap_strings[i].strptr)
+    while (ansi_a_dtap_strings[i].strptr)
     {
-       g_snprintf(str, 100, "0x%02x", ansi_a_ios401_dtap_strings[i].value);
-       dlg_dtap.entries[0] = g_strdup(str);
+       dlg_dtap.entries[0] = g_strdup_printf("0x%02x",
+                                             ansi_a_dtap_strings[i].value);
 
-       dlg_dtap.entries[1] = g_strdup(ansi_a_ios401_dtap_strings[i].strptr);
+       dlg_dtap.entries[1] = g_strdup(ansi_a_dtap_strings[i].strptr);
 
        dlg_dtap.entries[2] = g_strdup("0");
 
        gtk_clist_insert(GTK_CLIST(dlg_dtap.table), i, dlg_dtap.entries);
-       gtk_clist_set_row_data(GTK_CLIST(dlg_dtap.table), i, (gpointer) i);
+       gtk_clist_set_row_data(GTK_CLIST(dlg_dtap.table), i, (gpointer)(long) i);
 
        i++;
     }
 
-    ansi_a_stat_draw(NULL);
+    ansi_a_stat_draw(&ansi_a_stat);
+}
+
+
+static void
+ansi_a_stat_gtk_dtap_init(
+    const char         *optarg _U_,
+    void* userdata _U_)
+{
+    ansi_a_stat_gtk_dtap_cb(NULL, NULL);
 }
 
 
@@ -460,12 +464,10 @@ register_tap_listener_gtkansi_a_stat(void)
     GString            *err_p;
 
 
-    register_ethereal_tap("ansi_a,", ansi_a_stat_gtk_init);
-
-    memset((void *) &stat, 0, sizeof(ansi_a_stat_t));
+    memset((void *) &ansi_a_stat, 0, sizeof(ansi_a_stat_t));
 
     err_p =
-       register_tap_listener("ansi_a", &stat, NULL,
+       register_tap_listener("ansi_a", &ansi_a_stat, NULL,
            ansi_a_stat_reset,
            ansi_a_stat_packet,
            ansi_a_stat_draw);
@@ -478,8 +480,11 @@ register_tap_listener_gtkansi_a_stat(void)
        exit(1);
     }
 
-    register_tap_menu_item("ANSI/A-Interface BSMAP", REGISTER_TAP_GROUP_NONE
+    register_stat_menu_item("ANSI/A-Interface BSMAP", REGISTER_STAT_GROUP_TELEPHONY
         ansi_a_stat_gtk_bsmap_cb, NULL, NULL ,NULL);
-    register_tap_menu_item("ANSI/A-Interface DTAP", REGISTER_TAP_GROUP_NONE,
+    register_stat_cmd_arg("ansi_a,bsmap", ansi_a_stat_gtk_bsmap_init,NULL);
+
+    register_stat_menu_item("ANSI/A-Interface DTAP", REGISTER_STAT_GROUP_TELEPHONY,
         ansi_a_stat_gtk_dtap_cb, NULL, NULL ,NULL);
+    register_stat_cmd_arg("ansi_a,dtap", ansi_a_stat_gtk_dtap_init, NULL);
 }