remove some warnings
[obnox/wireshark/wip.git] / gtk / ansi_map_stat.c
index f93dac223219111ed0946897436eb4da0005f1b6..ecd54d3162b8b8eebb4db21c5f82783712566a20 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
 #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"
 #include "dlg_utils.h"
-#include "tap.h"
+#include <epan/tap.h>
 #include "../register.h"
 #include "../globals.h"
-#include "filter_prefs.h"
+#include "filter_dlg.h"
 #include "compat_macros.h"
 #include <epan/dissectors/packet-ansi_map.h>
-#include "ui_util.h"
+#include "gui_utils.h"
 
 
 typedef struct column_arrows {
@@ -62,7 +64,7 @@ typedef struct column_arrows {
 
 typedef struct _my_columns_t {
     guint32            value;
-    gchar              *strptr;
+    const gchar                *strptr;
     GtkJustification   just;
 } my_columns_t;
 
@@ -96,24 +98,21 @@ static void
 ansi_map_stat_reset(
     void               *tapdata)
 {
-    tapdata = tapdata;
+    ansi_map_stat_t    *stat_p = tapdata;
 
-    memset((void *) &stat, 0, sizeof(ansi_map_stat_t));
+    memset(stat_p, 0, sizeof(ansi_map_stat_t));
 }
 
 
 static int
 ansi_map_stat_packet(
     void               *tapdata,
-    packet_info                *pinfo,
+    packet_info                *pinfo _U_,
     epan_dissect_t     *edt _U_,
-    void               *data)
+    const void         *data)
 {
-    ansi_map_tap_rec_t *data_p = data;
-
-
-    tapdata = tapdata;
-    pinfo = pinfo;
+    ansi_map_stat_t    *stat_p = tapdata;
+    const ansi_map_tap_rec_t   *data_p = data;
 
 #if 0  /* always false because message_type is 8 bit value */
     if (data_p->message_type >= ANSI_MAP_MAX_NUM_MESSAGE_TYPES)
@@ -125,8 +124,8 @@ ansi_map_stat_packet(
     }
 #endif
 
-    stat.message_type[data_p->message_type]++;
-    stat.size[data_p->message_type] += data_p->size;
+    stat_p->message_type[data_p->message_type]++;
+    stat_p->size[data_p->message_type] += data_p->size;
 
     return(1);
 }
@@ -136,13 +135,11 @@ static void
 ansi_map_stat_draw(
     void               *tapdata)
 {
+    ansi_map_stat_t    *stat_p = tapdata;
     int                        i, j;
     char               *strp;
 
-
-    tapdata = tapdata;
-
-    if (dlg.win != NULL)
+    if (dlg.win && tapdata)
     {
        i = 0;
 
@@ -151,15 +148,15 @@ ansi_map_stat_draw(
            j = gtk_clist_find_row_from_data(GTK_CLIST(dlg.table), (gpointer) i);
 
            strp = g_strdup_printf("%d",
-                   stat.message_type[ansi_map_opr_code_strings[i].value]);
+                   stat_p->message_type[ansi_map_opr_code_strings[i].value]);
            gtk_clist_set_text(GTK_CLIST(dlg.table), j, 2, strp);
            g_free(strp);
 
-           strp = g_strdup_printf("%.0f", stat.size[ansi_map_opr_code_strings[i].value]);
+           strp = g_strdup_printf("%.0f", stat_p->size[ansi_map_opr_code_strings[i].value]);
            gtk_clist_set_text(GTK_CLIST(dlg.table), j, 3, strp);
            g_free(strp);
 
-           strp = g_strdup_printf("%.2f", stat.size[ansi_map_opr_code_strings[i].value]/stat.message_type[ansi_map_opr_code_strings[i].value]);
+           strp = g_strdup_printf("%.2f", stat_p->size[ansi_map_opr_code_strings[i].value]/stat_p->message_type[ansi_map_opr_code_strings[i].value]);
            gtk_clist_set_text(GTK_CLIST(dlg.table), j, 4, strp);
            g_free(strp);
 
@@ -232,8 +229,8 @@ ansi_map_stat_gtk_sort_column(
     gconstpointer      ptr1,
     gconstpointer      ptr2)
 {
-    GtkCListRow                *row1 = (GtkCListRow *) ptr1;
-    GtkCListRow                *row2 = (GtkCListRow *) ptr2;
+    const GtkCListRow  *row1 = ptr1;
+    const GtkCListRow  *row2 = ptr2;
     char               *text1 = NULL;
     char               *text2 = NULL;
     int                        i1, i2;
@@ -272,7 +269,7 @@ ansi_map_stat_gtk_win_destroy_cb(
 static void
 ansi_map_stat_gtk_win_create(
     ansi_map_stat_dlg_t        *dlg_p,
-    char               *title)
+    const char         *title)
 {
     int                        i;
     column_arrows      *col_arrows;
@@ -366,26 +363,12 @@ ansi_map_stat_gtk_win_create(
 }
 
 
-/*
- * Never gets called ?
- */
-static void
-ansi_map_stat_gtk_init(
-    char               *optarg)
-{
-    /* does not appear to be called */
-
-    optarg = optarg;
-}
-
-
 static void
 ansi_map_stat_gtk_cb(
     GtkWidget          *w _U_,
     gpointer           d _U_)
 {
     int                        i;
-    char               str[100];
 
 
     /*
@@ -402,8 +385,8 @@ ansi_map_stat_gtk_cb(
     i = 0;
     while (ansi_map_opr_code_strings[i].strptr)
     {
-       g_snprintf(str, 100, "0x%02x", ansi_map_opr_code_strings[i].value);
-       dlg.entries[0] = g_strdup(str);
+       dlg.entries[0] = g_strdup_printf("0x%02x",
+                                        ansi_map_opr_code_strings[i].value);
 
        dlg.entries[1] = g_strdup(ansi_map_opr_code_strings[i].strptr);
 
@@ -419,7 +402,16 @@ ansi_map_stat_gtk_cb(
        i++;
     }
 
-    ansi_map_stat_draw(NULL);
+    ansi_map_stat_draw(&stat);
+}
+
+
+static void
+ansi_map_stat_gtk_init(
+    const char         *optarg _U_,
+    void* userdata _U_ )
+{
+    ansi_map_stat_gtk_cb(NULL, NULL);
 }
 
 
@@ -429,12 +421,10 @@ register_tap_listener_gtkansi_map_stat(void)
     GString            *err_p;
 
 
-    register_ethereal_tap("ansi_map,", ansi_map_stat_gtk_init);
-
     memset((void *) &stat, 0, sizeof(ansi_map_stat_t));
 
     err_p =
-       register_tap_listener("ansi_map", NULL, NULL,
+       register_tap_listener("ansi_map", &stat, NULL,
            ansi_map_stat_reset,
            ansi_map_stat_packet,
            ansi_map_stat_draw);
@@ -447,6 +437,7 @@ register_tap_listener_gtkansi_map_stat(void)
        exit(1);
     }
 
-    register_tap_menu_item("ANSI/MAP Operation", REGISTER_TAP_GROUP_NONE,
+    register_stat_menu_item("ANSI/MAP Operation", REGISTER_STAT_GROUP_TELEPHONY,
         ansi_map_stat_gtk_cb, NULL, NULL, NULL);
+    register_stat_cmd_arg("ansi_map", ansi_map_stat_gtk_init,NULL);
 }