Turn around the sequence of PATH, so the former PATH will be in front of the newly...
[metze/wireshark/wip.git] / tap-stats_tree.c
index 4c0f3a1925961a0dfeb635292d37a77e7c9b0c0e..c7996fd80d9f968a7d5f39d009c1fe603e2c0e14 100644 (file)
@@ -2,7 +2,7 @@
  * tethereal's tap implememntation of stats_tree
  * 2005, Luis E. G. Ontanon
  *
- * $Id$
+ * $Id$
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -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 {
@@ -52,13 +54,13 @@ static void draw_stats_tree(void *psp) {
        stat_node* child;
        
        s = g_string_new("\n===================================================================\n");
-       fmt = g_strdup_printf(" %%s%%-%us%%12s\t%%12s\t%%12s\n",stats_branch_max_name_len(&st->root,0));
+       fmt = g_strdup_printf(" %%s%%-%us%%12s\t%%12s\t%%12s\n",stats_tree_branch_max_namelen(&st->root,0));
        g_string_sprintfa(s,fmt,"",st->cfg->name,"value","rate","percent");
        g_free(fmt);
        g_string_sprintfa(s,"-------------------------------------------------------------------\n");
        
        for (child = st->root.children; child; child = child->next ) {
-               stat_branch_to_str(child,s,0);
+               stats_tree_branch_to_str(child,s,0);
        }
        
        s = g_string_append(s,"\n===================================================================\n");
@@ -67,40 +69,43 @@ static void draw_stats_tree(void *psp) {
        
 }
 
-static void  init_stats_tree(char *optarg) {
-       guint8* abbr = get_st_abbr(optarg);
+static void  init_stats_tree(const char *optarg) {
+       guint8* abbr = stats_tree_get_abbr(optarg);
        GString *error_string;
        stats_tree_cfg *cfg = NULL;
        stats_tree* st = NULL;
        
        if (abbr) {
-               cfg = get_stats_tree_by_abbr(abbr);
+               cfg = stats_tree_get_cfg_by_abbr(abbr);
 
                if (cfg != NULL) {
                        if (strncmp (optarg, cfg->pr->init_string, strlen(cfg->pr->init_string)) == 0){
-                               st = new_stats_tree(cfg,NULL,((guint8*)optarg)+strlen(cfg->pr->init_string));
+                               st = stats_tree_new(cfg,NULL,((guint8*)optarg)+strlen(cfg->pr->init_string));
                        } else {
                                st->filter=NULL;
                        }
                } 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 optarg '%s'",abbr,optarg);           
+               return;
        }
        
        error_string = register_tap_listener( st->cfg->tapname,
                                                                                  st,
                                                                                  st->filter,
-                                                                                 reset_stats_tree,
+                                                                                 stats_tree_reset,
                                                                                  stats_tree_packet,
                                                                                  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 +118,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_ethereal_tap(cfg->pr->init_string, init_stats_tree);
+       register_stat_cmd_arg(cfg->pr->init_string, init_stats_tree);
        
 }