From Ted Percival:
[obnox/wireshark/wip.git] / tap-stats_tree.c
index 9533ac533a6f4f06909da09d8ed57d698c0ba6da..e5784faf1fafc0fd4b9496d751d5d79c58391d69 100644 (file)
@@ -31,6 +31,8 @@
 #include <stdio.h>
 #include <glib.h>
 #include <epan/stats_tree_priv.h>
+#include <epan/stat_cmd_args.h>
+#include <epan/report_err.h>
 
 /* actually unused */
 struct _st_node_pres {
@@ -67,7 +69,7 @@ static void draw_stats_tree(void *psp) {
        
 }
 
-static void  init_stats_tree(const char *optarg) {
+static void  init_stats_tree(const char *optarg,void* userdata _U_) {
        guint8* abbr = stats_tree_get_abbr(optarg);
        GString *error_string;
        stats_tree_cfg *cfg = NULL;
@@ -80,16 +82,19 @@ static void  init_stats_tree(const char *optarg) {
                        if (strncmp (optarg, cfg->pr->init_string, strlen(cfg->pr->init_string)) == 0){
                                st = stats_tree_new(cfg,NULL,((guint8*)optarg)+strlen(cfg->pr->init_string));
                        } else {
-                               st->filter=NULL;
+                               report_failure("Wrong stats_tree (%s) found when looking at ->init_string",abbr);
+                               return;
                        }
                } else {
-                       g_error("no such stats_tree (%s) found in stats_tree registry",abbr);
+                       report_failure("no such stats_tree (%s) found in stats_tree registry",abbr);
+                       return;
                }
                
                g_free(abbr);
                
        } else {
-               g_error("could not obtain stats_tree abbr (%s) from optarg '%s'",abbr,optarg);          
+               report_failure("could not obtain stats_tree abbr (%s) from grg '%s'",abbr,optarg);              
+               return;
        }
        
        error_string = register_tap_listener( st->cfg->tapname,
@@ -100,7 +105,8 @@ static void  init_stats_tree(const char *optarg) {
                                                                                  draw_stats_tree);
        
        if (error_string) {
-               g_error("stats_tree for: %s failed to attach to the tap: %s",cfg->name,error_string->str);
+               report_failure("stats_tree for: %s failed to attach to the tap: %s",cfg->name,error_string->str);
+               return;
        }
 
        if (cfg->init) cfg->init(st);
@@ -113,7 +119,7 @@ void register_stats_tree_tap (gpointer k _U_, gpointer v, gpointer p _U_) {
        cfg->pr = g_malloc(sizeof(tree_cfg_pres));
        cfg->pr->init_string = g_strdup_printf("%s,tree",cfg->abbr);
 
-       register_tap_listener_cmd_arg(cfg->pr->init_string, init_stats_tree);
+       register_stat_cmd_arg(cfg->pr->init_string, init_stats_tree, NULL);
        
 }